Germany appeared to be heading for a routine win when they led 2-0 through Toni Kroos and Mario Gomez, his first goal since Euro 2012, after an hour.
But Harry Kane changed the course of the game with an opportunist goal before Vardy produced a moment of brilliance just three minutes after coming on as a substitute.
Nathaniel Clyne crossed from the right and the Leicester City striker stuck his foot out behind his standing leg to flick the ball between Germany goalkeeper Manuel Neuer and his near post.
Then Dier rose above the Germany defence to score with a thumping downward header from Jordan Henderson’s corner in the 91st minute.
It was the first time England had come back from two goals down to win since they beat Italy 3-2 in 1976 and the only time in history that Germany or the former West Germany had lost after blowing a two-goal lead at home.
Even though it was a friendly, it was still a memorable and deserved win for England’s inexperienced lineup, who were the more inventive team throughout.
“England deserved to win, even when we were 2-0 we had allowed England a lot of chances,” Germany coach Joachim Loew told ZDF television. “It has been a good lesson for our team.”
“At halftime I thought it was very unjust that we came in at 1-0 down,” England manager Roy Hodgson told ITV. “At 2-0 down I thought it was even more unfair…
“We were creating the better chances and to come back and score three goals was fantastic. The players must take great credit.”
England, refusing to be overawed, created several good openings in the first half without seriously testing Neuer.
But Germany went ahead in the 43rd minute when England goalkeeper Jack Butland sent a clearance straight to Mesut Ozil on the halfway line and he worked the ball to Kroos who scored with a swerving 25-metre shot.
Butland, injured making the clearance, was replaced by Fraser Forster, who was left powerless when Gomez got in front of Clyne to head Germany’s second in the 57th minute.
Kane began the fightback when he picked up a loose ball in the penalty area, turned past two defenders and scored with a shot into the far corner in the 61st minute.
Dele Alli had a shot blocked by Neuer’s foot, Vardy equalised and England should have won it in the 85th minute but 19-year-old Alli fired over from 12 metres with the goal at his mercy.
But Dier’s last-gasp goal made sure it did not matter to leave both team benches and the Olympiastadion crowd in a state of disbelief.