Bastian Schweinsteiger fired the hosts ahead with a penalty in the 61st minute and teenager Mario Gotze added another from a narrow angle six minutes later, his first goal for Germany.
Robinho reduced the arrears for Brazil with another penalty in the 71st minute only for half-time substitute Andre Schuerrle to restore Germany's 3-1 advantage nine minutes later.
Neymar pulled one back for the visitors in stoppage-time.
Brazil - much more lightweight than the team which played at last year's World Cup - failed to take their chances in an even first hour but ultimately fell well short of their opponents, who have won seven out of seven games in their Euro 2012 qualifying group.
"Since I took over the national team one year ago, this is the first team we have played a team who have been better than us over the 90 minutes," Brazil coach Mano Menezes told reporters.
"At the moment, they are better than us and they are a measuring stick. This is where we have to get, this is what we have to overtake."
Germany last beat the South Americans 2-1 in Cologne in 1993 with four Brazil wins and a draw in the subsequent five meetings.
Menezes, under pressure after his team's Copa America quarter-final exit last month, left playmaker Paulo Henrique Ganso on the bench and started with Fernandinho in midfield instead, with Robinho, Neymar and Alexandre Pato in attack.
The 2014 World Cup hosts weathered an early storm before settling down and looking the more dangerous side.
Pato wasted one chance when he took too long over his shot and Neymar's trickery caused Germany several anxious moments.
Pato missed two more chances either side of halftime, both following breaks down the right and the second ending with a delicate chip which went just wide of the far post.
Brazil, also let down by their poor finishing at the Copa America, paid the price when Lucio was judged to have tripped Toni Kroos and Schweinsteiger fired home the penalty.
Kroos also set up the second, releasing Goetze who beat the offside trap and scored from a narrow angle.
Philipp Lahm's trip on Dani Alves earned Brazil their penalty, converted by the inconsistent Robinho.
Schweinsteiger set up Germany's third by winning the ball off Andre Santos in the penalty area and pulling back for Schuerrle to fire home, the 20-year-old's third goal in six appearances.
Teenager Neymar finished the scoring with a low shot from the edge of the area.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.