Richarlison scored a hat-trick inside the first half-hour and following goals by Germany's Nadiem Amiri and Ragnar Ache to cut the lead to 3-2, Paulinho put the finishing touches on the Selecao's victory with a goal in the fifth minute of second-half stoppage time.
Story of the match
Brazil opened the scoring when Richarlison raced in behind the German defense to latch onto a through ball by Antony. The Everton striker forced German goalkeeper Florian Muller into a fine save with his first effort, but he made no mistake on the rebound.
He could have had a second on the quarter-hour mark when he pounced on a poor back pass by Amos Pieper, but he couldn't find a way to beat Muller despite being clean in on goal.
He did get his second in the 23rd minute, latching onto the end of a Guilherme Arana cross from the left and heading home at the near post, before going on to make it 3-0 just before the half-hour mark when he cut inside from the left and curled a right-footed shot home inside the far post from the edge of the penalty area.
Brazil could have had a fourth in the closing minutes of the first half when Muller dove to his left to stop a penalty kick by Matheus Cunha after a handball was called inside the penalty area.
Amiri got Germany on the board when his shot from the edge of the area deflected past goalkeeper Santos. Die Mannschaft were down to ten men when captain Maximilian Arnold was sent off in the 62nd minute.
In the 83rd minute, Ache trimmed the deficit further as he headed home inside the six-yard box to set up a grandstand finish. Paulinho cemented the Brazil victory in the 95th minute, finishing into the top corner to help the Selecao to the top of Group D.
Man of the match: Richarlison
It was always going to be an emotional match after the two sides staged a dramatic gold-medal final in 2016 and the Everton man made sure the outcome would be the same as he dominated Germany all over the field playing in a central midfield role.