The entanglement in quantum XY spin chains of arbitrary length is investigated via the geometric measure of entanglement. The emergence of entanglement is explained intuitively from the perspective of perturbations. The model is solved exactly and the energy spectrum is determined and analyzed in particular for the lowest two levels for both finite and infinite systems. The overlaps for these two levels are calculated analytically for arbitrary number of spins. The entanglement is hence obtained by maximizing over a single parameter. The corresponding ground-state entanglement surface is then determined over the entire phase diagram, and its behavior can be used to delineate the boundaries in the phase diagram. For example, the field-derivative of the entanglement becomes singular along the critical line. The form of the divergence is derived analytically and it turns out to be dictated by the universality class controlling the quantum phase transition. The behavior of the entanglement near criticality can be understood via a scaling hypothesis, analogous to that for free energies. The entanglement density vanishes along the so-called disorder line in the phase diagram, the ground space is doubly degenerate and spanned by two product states. The entanglement for the superposition of the lowest two states is also calculated. The exact value of the entanglement depends on the specific form of superposition. However, in the thermodynamic limit the entanglement density turns out to be independent of the superposition. This proves that the entanglement density is insensitive to whether the ground state is chosen to be the spontaneously $Z_2$ symmetry broken one or not. The finite-size scaling of entanglement at critical points is also investigated from two different view points. First, the maximum in the field-derivative of the entanglement density is computed and fitted to a logarithmic dependence of the system size, thereby deducing the correlation length exponent for the Ising class using only the behavior of entanglement. Second, the entanglement density itself is shown to possess a correction term inversely proportional to the system size, with the coefficient being universal (but with different values for the ground state and the first excited state, respectively).