York City defeated National League leaders Lincoln City to set up an FA Trophy final against Macclesfield Town.
Sean Raggett's header put Lincoln 1-0 up and forced extra time with the aggregate score level at 2-2, but Scott Fenwick converted a penalty in the 104th minute to seal York's victory.
York will play Macclesfield at Wembley after the Silkmen beat Tranmere 1-0 to complete a 2-1 win on aggregate.
Ollie Norburn's powerful strike in the 68th minute ensured the away win.
York, who are 22nd in the National League - 39 points behind Lincoln - came into the away leg of the semi-final with a 2-1 lead thanks to goals from Vadaine Oliver and Adriano Moke at Bootham Crescent.
But Lincoln, fresh from a run to the quarter-finals of the FA Cup, were the favourites and took the lead in the 64th minute when Raggett converted from Nathan Arnold's corner.
That goal took the game to extra time, but it was Fenwick, who came on as a substitute at the start of the extended period, who took his chance, beating goalkeeper Paul Farman after Terry Hawkridge handled Hamza Bencherif's shot.
Macclesfield, who sit ninth in the National League, travelled to Prenton Park to face third-placed Tranmere with things all square following a 1-1 draw last Saturday.
And having scored in the first leg, it was Norburn who proved the difference for the away side, taking down Steve McNulty's long ball to beat goalkeeper Scott Davies minutes after rattling the crossbar.
York and Macclesfield can look forward to the final on 21 May at Wembley, while Lincoln and Tranmere will now turn their full attention to achieving promotion from the National League.