Barcelona will need Messi on this form if they are to produce another miracle Champions League fightback against Juventus on Tuesday
Madrid: Lionel Messi kept Barcelona's title hopes alive with two goals and an assist to see off Real Sociedad 3-2 as Spain's top two edged five-goal thrillers ahead of next weekend's El Clasico.
Earlier on Saturday, Isco struck at the death to keep Real Madrid three points clear and with a game in hand at the top of the table after twice coming from behind to beat Sporting Gijon 3-2.
Barcelona will need Messi on this form if they are to produce another miracle Champions League fightback against Juventus on Tuesday from a 3-0 first leg deficit.
The Argentine is now just two off his 500th Barca goal as he smashed home an effort from 25 yards to open the scoring.
Messi then took his tally to 45 goals in 44 games this season with a far less spectacular finish as he bundled home from close range after Geronimo Rulli had saved from Luis Suarez.
However, Barca passed up the chance to enjoy a comfortable evening in a three-goal spell in as many minutes just before half-time.
Firstly, Samuel Umtiti turned Inigo Martinez's driven effort into his own net.
Paco Alcacer, deputising for the suspended Neymar, briefly restored Barca's two-goal lead with a composed finish from Messi's pass.
Yet, Sociedad scored again almost straight from kick-off as Xabi Prieto cushioned William Jose's cross into the bottom corner.
Barca struggled for control after the break, but were handed a let off by Sociedad's wild finishing.
Madrid can all but secure a first league title in five years with victory when they host Barca next weekend.
But not for the first time this season they needed a late show after Duje Cop and Mikel Vesga put Sporting in front early in both halves.
Isco's fine individual effort and a towering header from Alvaro Morata ensured neither lead lasted more than a few minutes.
And Isco sealed the comeback when he drilled home from the edge of the box.
"This is the spirit of Real Madrid," said Isco.
"It is in the DNA of this shirt and this badge, we have shown it so many times and again today. Until the referee blows the full-time whistle it is not over."
The Spanish international is yet to agree a new contract with his current deal expiring at the end of next season.
And Madrid coach Zinedine Zidane insists he wants Isco to stay despite his lack of starts and interest from Barcelona.
"You know what I think of Isco, he is a player I like a lot and his place is here."
Isco's late intervention bailed out his coach after Zidane made nine changes from the side that beat Bayern Munich in the first leg of their Champions League quarter-final in midweek.
Cristiano Ronaldo and Karim Benzema were left out of the squad entirely alongside the injured Gareth Bale, while Toni Kroos, Luka Modric and Marcelo had to settle for a place on the bench.
"I feel like I am unfair with those that don't play," added Zidane.
"There are 24 players that can play in all positions. It is the difficult part of this job."
Atletico Madrid warmed up for the second leg of their Champions League quarter-final against Leicester City with a comfortable 3-0 win over rock bottom Osasuna despite missing two penalties in the same game for the second time this season.
Coach Diego Simeone also left out a number of his first-team regulars with top scorer Antoine Griezmann on the bench for the full 90 minutes.
Yannick Carrasco's low strike and back-post header put Atletico comfortably ahead either side of half-time.
Left-back Filipe Luis then added his third goal in five games.
However, Atletico's problems from the spot continued as they have now failed to score any of their last six penalties in La Liga.
Carrasco was denied his hat-trick by a fine save from Salvatore Sirigu before the Italian 'keeper made an even better stop to deny Thomas Partey seconds later.
Victory takes Atletico four points clear of Sevilla in third.