The world champions progress to the competition's later stages courtesy of their 3-0 defeat of Greece which nudged them ahead of their Asian counterparts.
Brazil have stuttered throughout and will now face Germany shorn of confidence after failing to defeat Mexico and having now failed to beat Japan.
The South American giants had the perfect start when teenage sensation Robinho gave them the lead on just ten minutes after being fed by Ronaldinho.
Despite early advantage having been struck, Brazil failed to build on their lead and were exposed on 27 minutes when Shunsuke Nakamura managed to conjure a stunning leveller.
However, five minutes later and Brazil had regained the lead when Barcelona favourite Ronaldinho got himself off the mark after Robinho had returned his captain's contribution with an assist of his own.
Masashi Oguro's leveller two minutes from time ensured a nervous finish but despite Brazil's progression, Zico's side can return from Cologne with pride after holding the world champions to a credible draw.
JAPAN: Kawaguchi, Miyamoto, Hidetoshi Nakata, Tamada (Koji Nakata 46), Nakamura, Yanagisawa (Suzuki 73, Santos, Fukunishi, Kaji, Tanaka, Ogasawara (Oguro 46).
BRAZIL: Marcos, Lucio, Robinho, Kaka (Renato 62), Adriano (Julio Baptista 62), Ronaldinho, Ze Roberto (Edu 77), Cicinho, Juan, Leo, Gilberto.
Referee: Mourad Daami (Tunisia).
Greece 0 Mexico 0
MEXICO sealed top spot in Group B of the Confederations Cup after a 0-0 draw with Greece in Frankfurt.
In front of 20,000 spectators, Mexico picked up the necessary point which secured a semi-final showdown with Argentina in Hannover on Sunday.
Though there were no goals for the crowd to witness, there was plenty of goalmouth action, with both goalkeepers in sparkling form.
Oswaldo Sanchez was the first to be tested when he produced a brilliant double save to deny Zisis Vryzas on seven minutes.
Vryzas' header was pushed on to the bar and when he latched on to the rebound, his shot took a deflection before being beaten away by Sanchez.
His opposite number then Antonis Nikopolidis kept Mexico at bay with a smart stop to thwart Francisco Fonseca.
Angelos Charisteas was later denied by Sanchez before Mexico thought they had maintained their 100 percent record on 81 minutes.
Alberto Medina's volley finally beat Nikopolidis but the linesman's flag was raised to rule the goal offside and leave the teams to play out the draw.
The European champions ended bottom of Group B after previously losing 3-0 to Brazil and 1-0 to Japan.
Mexico, meanwhile, added the draw to their 2-1 win over Japan and a hard-fought 1-0 victory over Brazil to extend their unbeaten run to a record 20 games
GREECE: Nikopolidis, Vyntra, Charisteas, Basinas, Fyssas, Zagorakis, Giannakopoulos, Vryzas (Papadopoulos 61), Goumas, Kapsis (Tavlaridis 75), Amanatidis (Gekas 46).
MEXICO: Oswaldo Sanchez, Osorio, Mendez, Salcido, Rodriguez, Lozano (Rafael Marquez 73), Pardo (Medina 46), Morales, Pineda, Perez, Fonseca (Torrado 61).
Referee: Carlos Amarilla (Paraguay).