Kai Havertz and Robin Gosens got on the scoresheet as Germany picked up a much-needed victory in Group F over Portugal.
Veteran coach Joachim Low, who is leaving the national team after 15 years in charge next month, has faced plenty of criticism for his 3-4-3 formation but the tactics worked perfectly just when he needed it most.
Cristiano Ronaldo’s superb counter-attacking goal – his first against Germany – totally against the run of play had left the 2014 World Cup winners staring at a second successive early exit from a major tournament after only 15 minutes in Munich.
But Germany’s wide defenders, particularly the left-sided man-of-the-match Robin Gosens, came to their rescue as they forced two own goals from Manchester City’s Ruben Dias and Raphael Guerreiro.
Consequently, Portugal became the first European nation to concede two own goals in a single match at a major tournament and there have now already been more own goals in this tournament than at any other European Championship.
But Germany’s scoring was not over, with Kai Havertz and Gosens doubling their tally to leave Portugal looking ordinary, even with Diogo Jota’s consolation.
After their opening Group F defeat to France, Germany had to make an impact and were the better side throughout, having a brilliantly-converted early Gosens goal cancelled out as Serge Gnabry was flagged offside for attempting, but failing, to reach Mathias Ginter’s cross.
But they were caught cold for the first goal as, within the space of 14 seconds, Ronaldo headed clear a corner on the edge of his own six-yard area and sprinted 100 yards to tap home after Jota controlled Bernardo Silva’s diagonal pass on his chest before taking goalkeeper Manuel Neuer out of the game with his square pass.
It was the fourth successive shot on target Portugal had scored from and they could have doubled their lead but Dias took a header off Ronaldo at the far post only to direct the ball wide across goal.
Crossfield balls were to prove key throughout the match as Germany’s wing-backs Gosens and Joshua Kimmich started to find their range.
A raking pass from Kimmich was met by a volleyed Gosens cross-shot which was turned in by Dias under pressure from Havertz in the 35th minute.
Four minutes later Gosens was released down the left and cut inside to Thomas Muller, who tried to find Havertz in the centre.
The Chelsea midfielder missed the cross but Kimmich arrived at the far post to hammer the ball back across goal where Guerreiro turned it into his own net.
Portugal’s right-back Nelson Semedo was having a torrid time with Gosens proving unstoppable down the flank, and the Atalanta defender delivered another assist when, after a brilliant 51st-minute passing move which saw the ball worked across the width of the pitch from right to left, he crossed low for Havertz to score.
Both wing-backs then combined directly as Kimmich crossed for Gosens to head home on the hour – his last act of a superb performance before being substituted.
Victory appeared to be assured, but Liverpool forward Jota’s close-range finish from Ronaldo’s cut-back made it 4-2 and Germany’s nerves were shaken further when substitute Renato Sanches rattled a post from distance.