Raja Casablanca continued their dream run in the FIFA Club World Cup as the home favourites stunned Brazil side Atletico Mineiro in Marrakech to book a final meeting with Bayern Munich.
The hosts denied Ronaldinho a chance to win the competition for the first time, having reached the final with Barcelona in 2006.
The former FIFA World Player of the Year brought his side level with a brilliant free-kick, cancelling out Mouhcine Iajour's opener early in the second half.
But Iajour won a penalty which Mouhcine Moutouali converted in the 84th minute and Vivien Madibe sealed a famous win in stoppage time.
The Moroccan side will now take on European giants Bayern in Saturday's final in the capital.
The first half of Wednesday's semi-final was even, with neither goalkeeper unduly tested, but Raja made the breakthrough six minutes after the break.
A through-ball found a huge gap in the Atletico defence and Iajour ran on to it, taking one touch before firing into the far corner from the edge of the area.
Ronaldinho rolled back the years with an equaliser in the 63rd minute, curling a 25-yard free-kick from left of centre around the wall and in off the far post.
The Brazilians pressed in search of a second, with Fernandinho and Jo forcing saves from Khalid Askri.
But they were undone at the back as Iajour was fouled in the area by Rever.
The Atletico captain was booked, but the real punishment came from the foot of Moutouali, who sent Victor the wrong way with a cool penalty low into the right corner.
And Madibe sealed Raja's place in the final with a third goal four minutes into injury time.
There was still time for Moutouali to fire a shot against the bar as the Moroccans finished on a high.ulty radar as time ticked away in Marrakesh.