Second placers Barcelona keeps their title hopes alive, Messi scores twice as they fought hard to beat Real Sociedad
The champions are three points below Real Madrid, who have a game in hand, going into El Clasico next weekend.
Messi scored the Catalans a lead with the opener. Following up with a second, his 498th goal for the club.
Samuel Umtiti gave Real a fighting chance with an own goal.
Paco Alcacer made it 3-1 before Xabi Prieto ended the scoreline with a goal of his own.
Barcelona host Juventus on Wednesday in the Champions League quarter-final, having lost the first leg 3-0 in Italy.
But boss Luis Enrique decided he could not risk losing ground in the title race in order to keep his players fresh for that game. Playing with a full-strength team at Camp Nuo, but who were without the suspended Neymar.