The visitors had come into the game knowing victory would see them promoted to League One, but they were blown away by a first-half hat-trick from Brendan Kiernan and a further strike from Mark Beck before Kevin
Lokko fired home a dramatic 84th minute winner.
Simon Weaver made eight changes to the side that began the game at Carlisle last weekend, with only Joe Cracknell, Will Smith and George Thomson named in the starting line-up with one eye on Monday's FA Trophy Final.
The U's, ready to seize their opportunity, made the early running with Luke Hannant and Joe Ironisde testing Joe Cracknell in the opening five minutes.
From their first chance of the game Town took the lead though when Kiernan ghosted in at the near post to convert Ryan Fallowfield's low cross on seven minutes.
Five minutes later Town were two up. A clever Kiernan backheel freed Fallowfield who again delivered an inch perfect cross for Beck to convert home.
Rocked by the early blow, Cambridge responded when top scorer Paul Mullin shot just wide but they found themselves 3-0 down after Kiernan as fouled by Callum Burton, who was booked for the offence. Kiernan stepped up to convert the spot kick.
If Town thought the game was done and dusted the visitors had other ideas. Wes Hoolahan turned and shot inside the area to reduced the arrears before Hannant found himself with space to hit his effort past Cracknell.
Less than a minute later though Town had restored their lead. Burton failed to hold George Thomson's shot and Kiernan was on hound to pounce and tap home.
On the stroke of half-time Kiernan almost had a fourth as his curling effort from the edge of the area fell narrowly wide.
U's boss Mark Bonner rang the changes at half-time, bringing on Harrison Dunk and Jubril Okedina in attempt to get back into the game and within a minute of the restart Mullin's effort beat Cracknell but rolled agonisingly wide.
Mullin went even closer on 55 minutes when he forced Cracknell into a smart save at the far post but on the hour he converted from close range to again reduce the arrears to a single goal.
The frantic pace continued after the break and a pacy run from William Hondermarck resulted in Ed Francis's chip being turned away by Burton in the U's goal.
The visitors drew level with just over 15 minutes when Jay Williams was penalised for a foul in the area. Mullin stepped and made no mistake to bring the sides level.
Town responded positively though a threaded pass from Thomson found Kiernan who delivered a penetrating cross that evaded Beck by a matter of inches.
As the clock ticked down both sides were aiming to come away with the points and Town almost restored their lead when Thomson's shot was turned aside. From the resulting corner, however, a loose ball fell to Lokko who stroked home the winner.
Next up of course for Town is Monday's trip to Wembley where Town get set to face National League South Side Concord Rangers with the chance to end the season with some silverware.
Harrogate Town: Cracknell, Fallowfield, Smith, Lokko, Roberts (Burrell, 67), Thomson, Honermarck, Francis, Kiernan, Beck.
Subs not used: Belshaw, Falkingham, Muldoon, McPake, Andrews.
Goals: Kiernan (7, 20, 31), Beck (12), Lokko (84)
Booked: Williams (73)
Cambridge United: Burton, Knoyle, Iredale (Dunk, 45), Digby (Tracey, 89), Taylor, Drysdale (Okedina, 45), Hannant, Mullin, Hoolahan, Ironside, Boateng (May, 83)
Subs not used: O'Neil, McKenzie-Lyle, Alese.
Goals: Hoolahan (26), Hannant (29), Mullin (60, 73).
Booked: Burton (20)
Referee: Ollie Yates.