We show that the geometric phase of the ground state in the XY model obeys scaling behavior in the vicinity of a quantum phase transition. In particular we find that the geometric phase is nonanalytical and its derivative with respect to the field strength diverges at the critical magnetic field. Furthermore, the universality in the critical properties of the geometric phase in a family of models is verified. In addition, since the quantum phase transition occurs at a level crossing or avoided level crossing and these level structures can be captured by the Berry curvature, the established relation between the geometric phase and quantum phase transitions is not a specific property of the XY model, but a very general result of many-body systems.