Er-doped ZnO thin films have been prepared by using inductively coupled plasma enhanced physical vapor deposition at different O2:Ar gas flow ratio (R = 0:30, 1:30, 1:15, 1:10 and 1:6). The influence of oxygen partial pressure on the structural, optical and magnetic properties was studied. It is found that an appropriate oxygen partial pressure (R=1:10) can produce the best crystalline quality with a maximum grain size. The internal strain, estimated by fitting the X-ray diffraction peaks, varied with oxygen partial pressure during growth. PL measurements show that plenty of defects, especially zinc vacancy, exist in Er-doped ZnO films. All the samples show room-temperature ferromagnetism. Importantly, the saturation magnetization exhibits similar dependency on oxygen partial pressure with the internal strain, which indicates that internal strain has an important effect on the magnetic properties of Er-doped ZnO thin films.