The invention discloses a high-gain AlGaN ultraviolet avalanche photodetector which structurally and sequentially comprises components from bottom to up: an AlN template layer, an AlxGal-xN buffer layer, an n type AlxGal-xN layer, an i type AlyGal-yN absorbing layer, an n type AlyGal-yN separating layer, an i type AlyGal-yN multiplication layer, a p type AlzGal-zN layer and a p type GaN layer, wherein an n type ohmic electrode is led out from the n type AlxGal-xN layer, a p type ohmic electrode is led out from the p type GaN layer, x is larger than y, y is larger than z, and z is larger than 0. The invention further discloses a preparation method of the high-gain AlGaN ultraviolet avalanche photodetector. The high-gain AlGaN ultraviolet avalanche photodetector adopting an SAM (security account manager) structure can obviously reduce impressed voltage and dark current during APD (avalanche photodiode) avalanche breakdown, and facilitates the increase of APD avalanche multiplication factors.