Phosphorus introduction into Mg-doped aluminium gallium nitride ((Al)GaN) epilayers to enhance the acceptor activation is a possible strategy for a p-type conductivity improvement in III-nitride wide-bandgap semiconductors. To date, P-implanted Mg-doped (Al)GaN structures have not been systematically evaluated, regarding structural verification and elemental distribution. Here, comprehensive studies of P ions impact on structural degradation are presented. Furthermore, a post-implantation annealing conducted at different temperatures is examined as well. The results demonstrated that the structural changes in the examined compounds, namely GaN and Al0.1Ga0.9N, due to P implantation and a subsequent recovery by thermal annealing follow similar trends. Interestingly, it was revealed that P diffusion length is higher in AlGaN than in GaN, possibly due to higher oxygen content in Al-containing compounds, analogous to Mg dopant. Additionally, the initial Mg concentration in (Al)GaN is crucial because too high Mg doping could be the main cause of electrical properties degradation of (Al)GaN heterostructures after P ion implantation.