Gabriel Barbosa and Pedro both scored twice as Flamengo beat Al Ahly 4-2 in a pulsating Club World Cup third-place play-off on Saturday.

Flamengo went ahead in the 11th minute when Barbosa rolled in from the penalty spot after Ali Maaloul had brought down Guillermo Varela.

But Al Ahly levelled seven minutes before the interval at Stade Ibn-Batouta in Tangier when Ahmed Abdelkader headed home Maaloul's corner.

Maaloul's eventful game took another twist in the 58th minute when his tepid spot-kick was kept out by Santos after Mohamed Sherif had been fouled by Thiago Maia in the area.

However, Al Ahly did not have to wait long to take the lead as Abdelkader cut in from the left and curled in a fine finish with his right foot just two minutes later.

Flamengo were handed a lifeline soon after when Khaled Abdelfattah received a straight red card for a foul on Ayrton Lucas just outside the area, with the initial penalty award overturned after a pitchside review.

The Brazilian side took full advantage of their numerical superiority, levelling through Pedro's hooked finish in the 77th minute before taking the lead courtesy of Barbosa's second penalty after Mohamed Hany handled in the area.

Pedro then put the seal on the victory in stoppage time, rolling past Mohamed El-Shenawy after some poor defending by Al Ahly.