The two sides had never met before, and it was the first time Raja Casablanca had faced opponents from Oceania, while Auckland City had their best result against an African opponent at a Club World Cup in a 3-2 victory over TP Mazembe in the 2009 fifth place play-off.
The Moroccan national league holders had the first chance in the seventh minute of the match when Raja captain Mohsine Moutaouali crossed from the right to the far post where Adil Karrouchy volleyed his shot over the bar from close range.
Supported by their passionate home crowd, Raja came close in the 22nd minute when Moutaouali threaded a beautiful through ball to Mouhssine Iajour who was denied by Auckland goalkeeper Tamati Williams inside the box, who saved with his leg.
Raja dominated possession for the majority of the first half, but Auckland were able to break in the 29th minute when Roy Krishna had his shot blocked.
The deadlock was broken when Karrouchy found Iajour in the box who slotted his left-foot shot into the far corner past Williams to send Agadir into a frenzy.
The hosts brought their momentum from the first half into the second as Moutaouali curled a shot from the left edge of the box only to be denied by the post.
Auckland asserted themselves on the attack when Christopher Bale shot wide from 16 metres out.
The Agadir Stadium turned quiet when Mohamed Oulhaj and Ismail Benlamalem ran into each other, failing to clear effectively, leaving Fijian Krishna an open path to score the equaliser past Khalid Askri.
After Krishna's equaliser, Raja continued to attack when clever passing between Moutaouali and Abdelilah Hafidi led to a pass for Kuoko Guehi who had hist shot blocked by John Irving in the 77th minute.
The tie looked to be heading into extra time when Karrouchy crossed from the goalline to find Oulhaj whose headed shot was initially saved by Williams only to fall to the feet of Hafidi who tapped in the rebound to send Agadir Stadium into delirium.
The Moroccans will now face CF Monterrey in the quarter-finals in Agadir on 14 December.