We investigated the surface stress change of plasma-polymerized allylamine films on 2 μm thick silicon micromechanical cantilever substrates induced by ultraviolet light (UV) irradiation. Compressive surface stress was generated during the UV irradiation of the plasma-polymerized films in a dry environment, whereas tensile stress was measured in a humid environment. Fourier transform infrared spectroscopic analysis indicated two mechanisms taking place depending on the environmental conditions. These were attributed to crosslinking and oxidation reactions of the plasma polymer. UV irradiation of plasma polymerized allylamine films at defined humidity suggests a feasible method for achieving tensile and compressive surface stress patterning.