Paul Ritchie scored the crucial penalty as Partick Thistle secured a return to the First Division with a 4-2 shoot-out victory after winning 2-1 on the day.
The Thistle players celebrate promotion
Peterhead looked to have put the game beyond Thistle when Martin Bavidge put them ahead early on, but Mark Roberts quickly made it 3-2 on aggregate.
It seemed as though the home side would hold on, but Billy Gibson scored with a deflected free kick in the last minute.
Extra-time produced no more goals and Ritchie converted the crucial penalty.
It looked good for Peterhead after just five minutes when they stretched their aggregate lead to 3-1.
Martin Wood sent Bavidge clear and he unleashed a right-foot shot that flew into the far corner of the net.
But Partick were level three minutes later, Roberts chesting the ball down before netting from close range.
Billy Gibson celebrates his last-minute strike
Both teams had chances to score again before the visitors dramatically levelled on aggregate two minutes into stoppage time, when Gibson's free-kick took a wicked deflection off the defensive wall.
With neither side able to claim victory in extra-time, the match went to penalties.
Thistle scored their first three penalties, but Peterhead's Dougie Cameron and Keith Gibson missed.
Though Will Snowdon missed Thistle's fourth, Ritchie stepped up to score the decisive kick and put the Jags back into the First Division.
Peterhead: Mathers, Calvin Shand (Gibson 22), Cameron, Tully, Perry, Hegarty, Sharp, Buchan, Bavidge, Wood (Linn 84), Nicol.
Subs Not Used: Youngson, Michie, McCafferty.
Booked: Hegarty, Tully.
Goal: Bavidge 5.
Partick: Arthur, Murray, McCulloch (Nicholas 75), Snowdon, Smyth, Boyd (Ritchie 75), James Gibson, Billy Gibson, McConalogue (Kilgannon 94), Roberts, Strachan.
Subs Not Used: Colin Stewart, Hodge.
Booked: Murray, Boyd, McCulloch, Smyth, Kilgannon.
Goals: Roberts 8, Billy Gibson 90.
Ref: A Freeland