We have studied the properties of Mg-doped GaN epilayers grown by molecular beam epitaxy (MBE) with ammonia as nitrogen source. GaN p-n homojunctions has been developed to determine the optoelectronic characteristics of the junctions as a function of the p-type GaN growth conditions. It is shown that the electrical characteristics strongly depend on the Mg flux and the growth temperature. As a result, the junction characteristics have been drastically improved and state of the art MBE-grown p-type layers have been obtained: the hole concentration, the mobility, and the resistivity are 1 x 10(18) cm(-3), 9 cm(2)/V s, and 0.75 Omega cm, respectively. These characteristics lead to an increase of the homojunction light emitting diode (LED) optical output power by two orders of magnitude. To further assess the quality of these MBE-grown p-type layers, we have prepared a hybrid LED which consists of an InGaN/GaN quantum well active structure grown by metal organic vapor phase epitaxy followed by a p-type region grown by MBE. An optical, power in the milliwatt range at 20 mA is demonstrated confirming thereby the quality of low temperature MBE-grown p-type layers. (c) 2008 American Institute of Physics.