Raja Casablanca scored twice in the last 10 minutes to stun Brazil's Atletico Mineiro 3-1 in their Club World Cup semi-final on Wednesday and earn a place in the final against Bayern Munich.
Mohaine Moutaouali fired home a controversial penalty in the 83rd minute and Vivien Mabide wrapped it up in stoppage time with a breakaway goal amid chaotic scenes.
Mouhssine Iajour had given Raja, who qualified as champions of host nation Morocco, the lead early in the second half before Ronaldinho curled a free kick in off the post to level for the South American champions.
It will be only the second time since the tournament has been played in its current format in 2005 that the final has not been between a South American and European team.
With seven minutes to go the game appeared to be heading towards extra-time before Rever brought down Iajour in the box, allowing Moutouali to become the hero, smashing home the ball with just minutes remaining.
Then deep into injury time, Central African international Vianney Madibe capped a glorious night in Raja's history with their third goal, to the delight of their Tunisian-born 63-year-old coach Faouzi Benzarti, who has enjoyed three spells at the helm of his national team and also won the African Champions League in 1994 with Esperance.
There were incredible scenes at the end as the Raja players surrounded Ronaldinho to ask for his shirt and took off his boots.
Mineiro, who had spent six months dreaming of the tournament since they won the Libertadores Cup, slunk disconsolately away, leaving their army of 10,000 fans with a long, painful journey back to Belo Horizonte.
Raja look more confident against a nervous, disjointed Atletico team and twice came close to taking the lead before half time.
It was no surprise when they went ahead eight minutes into the second half when Iajour was sent clear on the right and fired a low shot past Victor.
Atletico appeared to be losing their way but grabbed an equaliser out of the blue when Ronaldinho curled in his free kick just after the hour.
The goal failed to inspire the Brazilians and Raja regained the lead in the 83rd minute when Rever was adjudged to have tripped Iajour, although replays suggested no contact was made, before Mabide produced the coup de grace in the fourth minute of stoppage time.