Germany started brightly and thought Gosens had given them the lead, only for the goal to be ruled out for offside against Gnabry.
Ronaldo then shocked Low’s men with a counter-attacking opener before own goals from both Dias and Guerreiro gave the Germans a half-time lead.
Gosens met another cross from the right at the back post but this time he drilled the ball back across goal on the volley.
Havertz and Dias both tried to get to it first and even though it was initially credited to Havertz, replays appeared to show that the ball had cannoned off the shin of Dias past Rui Patricio.
Three minutes later, Germany were ahead. Thomas Muller tried to loft the ball into the Portugal box and when the ball was headed straight back to him by Pepe, he tried again.
This time, his pass found Havertz in the middle and even though Havertz could not make proper contact, it ran on to Kimmich.
Kimmich turned the ball back and Portugal fullback Raphael Guerreiro shinned it high into the roof of his own net.
Gosens extended their advantage when Muller played the ball into his path, he provided another brilliant cross that Havertz turned into the net from close range.
But Jota’s tap-in reduced the deficit when Ronaldo hooked it back across goal over the head of Neuer and Jota forced it over the line as Rudiger made a desperate last-ditch attempt to clear it.
Santos’ men pushed on, however, they failed to find another goal, meaning Germany run out 4-2 victors at the Allianz Arena.
Germany’s 4-2 win blows Group F wide open, especially when considering France dropped points against Hungary earlier today.
Low’s men overtake Portugal to move up to second as they face Hungary on Wednesday.
Santos’ men, who drop down to third courtesy of their head-to-head record against today’s opponents, next challenge France on the same day.