The fixture was a fundraiser for research into amyotrophic lateral sclerosis (ALS), the most common form of motor neurone disease (MND), which former Barca goalkeeper and coach Juan Carlos Unzue was diagnosed with in 2020.
Cole Palmer drew City level, but the home side looked to have won it when substitute Memphis Depay, who has been told to find a new club before the transfer window closes next week, turned home 10 minutes from time.
However, there was a final twist in the tale when City were handed a late penalty after Erling Haaland appeared to trip himself up in the box accidentally — even the Norway striker looked perplexed at the decision — and Mahrez made no mistake from 12 yards.
Unzue played alongside City coach Pep Guardiola at Camp Nou between 1988 and 1990 and was later part of his coaching staff between 2008 and 2010, with Barca winning six trophies in 2009 while current Blaugrana boss Xavi Hernandez played in the side.
He returned to Barcelona as Luis Enrique’s assistant in 2014 following spells in charge of Numancia and Racing Santander, helping the Catalan club win their second ever Treble the following season.
Unzue, who gave an emotional pre-game speech, took the honorary kickoff from his wheelchair on the pitch before taking his place in the City dugout alongside Guardiola for the opening stages.
Both teams made changes from their previous games. Jules Kounde, not yet registered for LaLiga action due to Barca not having room within their spending cap, started for the home side, as did Aubameyang, who is in talks to join Chelsea.
Goalkeeper Inaki Pena failed to deal with a simple cross into the box and his fumble was turned in by Alvarez.
A Kounde error handed Palmer a chance to double City’s advantage, but he blazed over and moments later Barca levelled when Aubameyang fired in at the near post from Raphinha’s free kick.
City were the dominant side after the break. Pena made amends for his error with a fine double save from Alvarez but the Premier League side were caught on the counter.
Memphis couldn’t quite make it around Ortega but the ball fell kindly to De Jong and the Netherlands midfielder converted from close range.
City returned to the attack and were soon level when Mahrez found Joao Cancelo on the overlap to set up a tap-in for Palmer.
As both coaches made wholesale changes, the arrival of Haaland was warmly welcomed by the home crowd. His warmup drew a loud cheer.
Meanwhile, Memphis restored Barca’s lead after good work from Sergi Roberto before a lengthy stoppage due to an injury to City youngster Luke Mbete, who left the pitch on a stretcher after receiving treatment for almost 10 minutes.
That led to an extended period of stoppage time, with Haaland’s tumble and Mahrez’s penalty expertise earning a draw for City.