(CNN) -- Argentina star Lionel Messi came off the bench to score twice as nine-man Barcelona recovered to beat Racing Santander 2-1 and move 12 points clear of arch-rivals Real Madrid at the top of the Spanish Primera.
Messi celebrates his second and winning goal at Racing Santander.
On a weekend of milestones in Spain, Messi's winning goal was Barca's 5,000 in the league, while Raul scored his 307th goal as Real beat Numancia 2-0 on Saturday night.
It draws Raul level with the great Alfredo di Stefano on the Real all-time scoring charts.
The win temporarily cut the gap on the runaway leaders to nine points and when Nikola Zigic put Racing in front from the penalty spot in the 56th minute an upset was on the cards.
But Messi, rested by Pep Guardiola, worked his magic after coming on, with an equalizer five minutes later.
His 81st minute winner sealed victory but the gloss was taken off the Barca win as Rafael Marquez,.earlier booked in the penalty incident, and Gerard Pique were sent off for fouls.
It was the ninth straight league win for the Catalan giants, who are unbeaten in 20 league games after defeat in their opener.
It leaves them on 56 points from 21 games with defending champions Real on 44 and Sevilla, who were playing their 21st round on Sunday night, on 38.
Barca beat Espanyol in midweek in the Spanish Cup to stay on course for the domestic double and are also in the last 16 of the Champions League.
In other matches on Sunday, Villarreal continued their poor run with a 3-0 defeat to Deportivo La Coruna while Atletico Madrid were beaten 2-1 at home by Valladolid.