Raja Casablanca converted a late penalty to upset Ronaldinho's Atletico Mineiro 3-1 and become the first team from outside of Europe or South America to reach the Club World Cup final on Wednesday.

The Moroccan club will play Champions League winner Bayern Munich after captain Mohsine Moutaouali converted an 84th-minute penalty, awarded when Atletico defender Rever tripped Mouhssine Iajour inside the area.

Iajour had put the local favorite ahead in the 51st before more than 35,000 fans at the Marrakech Stadium before Ronaldinho equalized for the Brazilian team from an exquisite free kick in the 63rd.

But Atletico coach Cuca could only look on in silence as substitute Vivien Mabide put the result beyond doubt with a stoppage time goal.

Despite Ronaldinho's equalizer, the Brazilian playmaker was the one leaving the field red-eyed after the Copa Libertadores champion's unexpected loss.

Ronaldinho was mobbed by jubilant Raja fans who competed for his jersey, some even untying laces to remove his shoes as a souvenir of perhaps the club's most memorable night of football.

Atletico certainly did not look leaps above Raja, which used its speed on the counter to upset Atletico's backline of Leonardo Silva and Rever, who was exposed throughout but especially in the deciding spot kick.

Raja defender Zakaria El Hachimi celebrated the penalty by performing `the worm' along the grass.

The goal came as Atletico looked set on avoiding an embarrassing upset, but the Brazilians' poorly organized defense left it open to too many attacks as Iajour unleashed a low shot in-between Lucas' legs to open the scoring.

Ronaldinho stuck to the script and provided his team's heroics as he curled a free kick over the defensive wall to curl inside the far post to equalize, but Mabide had no trouble volleying home Moutaouali's shot after it came off the crossbar.

Atletico will play Guangzhou Evergrande of China in Saturday's third-place game.