The present invention relates to an AlGaInN based optical device fabricated by a new p-type AlGaInN:Mg growth method and method for manufacturing the same, including a p-type nitride semiconductor layer that is grown using both NH3 and a hydrazine based source as a nitrogen precursor, thereby an additional subsequent annealing process for extracting hydrogen is not necessary and thus the process is simple and an active layer can be prevented from being thermally damaged by subsequent annealing.