Brazil advanced to a FIFA Confederations Cup semi-final against hosts Germany after a 2-2 draw with Japan in Cologne secured them second place in Group B behind Mexico on Wednesday 22 June.

Carlos Alberto Parreira's men needed only a point to make sure of progressing and this result means they finished level on four points with the Japanese but advance on goal difference. For a long while they looked like taking all three points courtesy of first-half goals from Robinho and Ronaldinho.

The former opened the scoring on ten minutes, from Ronaldinho's assist, and after Shunsuke Nakamura's explosive 27th-minute equaliser for Japan, he returned the compliment by setting up his captain to score. However, Masashi Oguro's 88th-minute equaliser ensured a nervy finish - and meant Zico's side can return to Asia with some pride.

For Japan, of course, a first win in seven attempts against Brazil was always asking a lot but they thought they had made the perfect start inside three minutes when Mitsuo Ogasawara's pass picked out Akira Kaji's break down the inside-right channel and the full-back beat Marcos with a fine first-time finish. Unfortunately for him, the linesman's flag ruled out what would have been his first international goal.

If that was a warning for Brazil, they duly responded. Carlos Alberto Parreira may have made four changes from the side beaten by Mexico – in came Marcos, Leo, Juan and Gilberto Silva for their first starts of the tournament – but, tellingly, in attack all of the 'Fab Four' remained. And even in this match's early moments, when these front men burst forward, they seemed capable of playing at a different speed to the Japanese.

One combination between Robinho and Kaka produced a far-post chance for Adriano, who, at full stretch, turned the ball wide. By the tenth minute, Brazil were in front as they turned defence into attack to strike just moments after facing a corner at their own end. Ronaldinho sped forward and with options to his right and left, went left with a short pass to the advancing Robinho and the Santos man sent a low shot past Yoshikatsu Kawaguchi and inside the far post

In the 17th minute it was so nearly 2-0 as Kaka flashed a shot against a post and before Japan could clear their lines, Ronaldinho was there drawing a fingertip save from Kawaguchi.

Japan's heads did not drop, however, and they went desperately close to an equaliser in the 24th minute when Atsushi Yanagisawa headed against the crossbar from Ogasawara's free-kick. Three minutes later, they did draw level as Nakamura, collecting a short Takashi Fukunishi pass 25 metres from goal, beat Marcos in spectacular fashion.

Confidence was now coursing through Japanese veins but the feeling would not last long. Five minutes, to be precise before Robinho and Ronaldinho combined to restore Brazil's lead. Robinho teased Kaji on the left flank before crossing low into the penalty area where Ronaldinho arrived to stab a shot past Kawaguchi.

Brazil may have ended the first period on top yet they almost let Japan back into the match seconds after the restart as a stray back-pass let in Yanagisawa but Marcos flew out of his goal to smother the shot. Zico had sent on Oguro, the match-winner against Greece, in place of Keiji Tamada at the break and on 55 minutes the substitute very nearly created a second goal for Nakamura as his speed carried him beyond the Brazil back line and the ensuing cross was met by Nakamura who beat Marcos but not Cicinho on the line.

That looked like being the last chance for Zico's side as Brazil went in search of a third. Kawaguchi stopped a Cicinho shot, then saved bravely from Juan from the ensuing corner before first Juan and then Lucio failed to turn the loose ball home.

Brazil substitute Julio Baptista also threatened a third with a weaving run and shot at Kawaguchi while Robinho flashed a shot wide. For Brazil the match seemed won but they received a late scare when Oguro raised the noise level in the stadium when he was quickest to react after Nakamura's free-kick had come back off a post. The little striker almost had the Japanese in dreamland in the dying seconds as he connected with a cross to the far post but Marcos was equal to his effort.