The structural stability and magnetic properties of a grain boundary (GB) formed by aligning two ZnO single crystals oriented at an angle of 45 is investigated by density functional theory, using generalized gradient approximation (GGA) and taking the U parameter into consideration for the 4f impurity states. We found that the GB is stable with no dangling bonds and inter-granular structures. The stability of defects such as Gd substituted to the Zn site (Gd Zn ), Zn vacancy (V Zn ) and O vacancy (V O ) as well as defect complexes Gd Zn -Gd Zn , Gd Zn -V Zn , and Gd Zn -V O are analyzed using formation energy calculations. It is found that Gd Zn -Gd Zn clusters prefers to form at the GB. The spin polarization at the Gd Zn sites is too localized and the exchange coupling energy is insufficient to overcome the thermal fluctuations. However, we show that the presence of V Zn increases the hybridization between p orbitals of O as well as d orbitals of Zn, which can assist in increasing the magnetic polarization of the system. This work advances the understanding of the ferromagnetism in Gd-doped ZnO, indicating that Gd clustering at the GB is not likely to contribute to the ferromagnetism.