Pep Guardiola's side had led through goals by Xavi and Lionel Messi inside the opening 12 minutes at Camp Nou, before Ruben Castro pulled one back after half an hour and Roque Santa Cruz made it 2-2 in the second half.
The visitors had Mario sent off with 19 minutes remaining for a second booking before Alexis Sanchez restored the lead 15 minutes from time and Messi made it 4-2 with a late penalty.
Athletic Bilbao produced a superb first-half display to ease past Levante 3-0 and move to within four points of their fourth-placed opponents in the race for a Champions League place.
Fernando Amorebieta opened the scoring after 11 minutes as he headed home Markel Susaeta's corner.
Oscar de Marcos helped make it 2-0 as he danced past the Levante defence and floated an excellent ball across for Fernando Llorente to head home.
Following Levante defender Juanfran's dismissal for a second booking, Mikel San Jose was left all alone to head in his second goal of the week from Inigo Perez's cross.
Diego Simeone secured his first win as Atletico Madrid coach as his side dominated from start to finish to beat a poor Villarreal 3-0.
The hosts had already wasted a number of chances before Radamel Falcao finally broke the deadlock five minutes before half-time with an easy finish after great work from Adrian Lopez down the right.
The same two players combined to create Atletico's second just after the break as this time Adrian's backheel set the Colombian free inside the area and he was brought down by Gonzalo Rodriguez. Falcao subsequently stepped up to take the resulting penalty and calmly doubled his tally for the day.
Diego finally added a third as he side-footed past Diego Lopez 10 minutes from time.
A stunning injury-time winner from substitute Oscar Trejo earned Sporting Gijon a vital 2-1 win over European hopefuls Malaga that helped moved them away from the foot of the table.
Although they started the night seven points clear of rock-bottom Real Zaragoza, Manuel Preciado's men are very much in the thick of the relegation dogfight in the places above.
They appeared destined to stay there too, when Ruud van Nistelrooy cancelled out Alejandro Galvez's opener with just three minutes left.
But, halfway through the time added on, Trejo chested down a pass from Alberto Rivera and unleashed a dipping half-volley that left Willy Caballero grasping at thin air.
Osasuna's 11-game unbeaten run at home came to an end as Racing Santander continued their excellent start to Juanjo Gonzalez's reign with a 2-0 win at the Reyno de Navarra as Christian Stuani scored twice from the penalty spot.
Real Madrid carved out a hard-fought 2-1 win against Real Mallorca on Saturday night to extend their lead over Barcelona to eight points.
Mallorca had looked on course to claim a shock win after Tomer Hemed gave them a 39th-minute lead but Madrid drew level through substitute Gonzalo Higuain 18 minutes from time before Jose Maria Callejon netted an 84th-minute winner for Jose Mourinho's men.
Antoine Griezmann scored the only goal as listless Valencia slipped to a 1-0 defeat against Real Sociedad, ensuring they stayed four points behind Barca.
Sevilla's run without a league win stretched to four games as Espanyol produced a solid defensive performance to come away from the Sanchez Pizjuan with a 0-0 draw.
A late own goal denied new Real Zaragoza coach Manolo Jimenez a victory on his home debut as Getafe snatched a 1-1 draw at La Romareda.
Jimenez's side took a 38th-minute lead through Maurizio Lanzaro, but with 11 minutes to go Zaragoza defender Javier Paredes inadvertently put through his own net to help Getafe salvage a point.
Goals by Michu and Piti earned Rayo Vallecano a Primera 2-1 win at Granada who finished the game with 10 men.
The home side hit back through Fran Rico in the last five minutes but they also had Inigo Lopez dismissed in injury time.