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 vacancy (V) and O vacancy (V) as well as defect complexes Gd-Gd, Gd-V, and Gd-V are analyzed using formation energy calculations. It is found that Gd-Gd clusters prefers to form at the GB. The spin polarization at the Gd sites is too localized and the exchange coupling energy is insufficient to overcome the thermal fluctuations. However, we show that the presence of V 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.