The invention discloses a preparation method of a p type GaN and AlGaN 
semiconductor material. A substrate, and a buffer layer or a 
transition layer, an unintended doped layer and an 
acceptor doped layer grown on the substrate from bottom to top are contained; in a growth process of the structure, 
ammonia or 
nitrogen dimethylhydrazine is used as a five-group 
nitrogen source; trimethyl 
gallium or TEGa used as a three-group 
gallium source, 
trimethylaluminium or triethyl aluminum used as a three-group 
aluminium source, and 
trimethylindium or TEIn used as a three-group 
indium source are collectively called three-group 
metal sources; and the 
trimethylindium or the TEIn is also used as a surface 
active agent and used in the 
acceptor doped layer. According to the method, the 
trimethylindium or the TEIn is used as the surface 
active agent to assist growth, and simultaneously, the 
acceptor doped layer is prepared by adopting a 
delta doping method. According to the method, the 
doping efficiency of acceptor doped 
magnesium atoms is increased, and simultaneously, the self-
compensation effect is suppressed, so that the p type GaN and AlGaN 
semiconductor material with favorable crystalline quality and high hole concentration is obtained.