Barcelona's Lionel Messi fights for the ball against Valencia's Carlos Soler during the Spanish La Liga soccer match between Valencia and Barcelona at the Mestalla stadium in Valencia, Spain, Sunday, May 2, 2021. AP
Lionel Messi missed a penalty but still scored twice, including an exquisite free-kick, as Barcelona edged a five-goal thriller with Valencia on Sunday to stay within touching distance of the top of La Liga.
After Real Madrid and Atletico Madrid both won on Saturday, there was no margin for error at Mestalla, where Barca's 3-2 win reduced the gap behind Atletico back to two points, now with four games left to play.
Gabriel Paulista headed Valencia in front early in the second half and Messi missed a penalty, only to smash in from the resulting scramble.
Griezmann and a superb Messi free-kick looked to have made the victory secure but Carlos Soler's stunning strike from distance in the 83rd minute left Barcelona holding on at the end, a nerve-wracking win meaning they could overtake Atletico Madrid next weekend if they beat Diego Simeone's side at Camp Nou.
After a frantic week in which Real Madrid drew against Real Betis, Atletico lost to Athletic Bilbao and Barca were beaten on Thursday by Granada, order has been restored to some extent this weekend, with all the top three back to winning ways.
Sevilla are now six points behind Atletico and will need to beat Athletic Bilbao on Monday to stay in the mix ahead of their own crunch game next weekend away at Real Madrid.
Barcelona's key strengths and weaknesses were clearly demonstrated against Valencia where again they proved themselves to be the most creative team in the division while also showing their vulnerabilities again at the back.
And if they have one trump card during the run-in, it is Messi, whose double takes his La Liga tally to 28 goals for the season, seven ahead of Karim Benzema and even more remarkable given his relatively slow start. The Argentinian now has seven in his last five games.
Ronald Koeman was banned from the bench after being sent off against Granada, with assistant coach Alfred Schreuder in his place on the line.
Barcelona had the better of the chances in the first half Valencia could take encouragement from some clear openings on the break.
They should have capitalised early in the second half as Goncalo Guedes ran onto Soler's pass but failed to beat Marc-Andre ter Stegen with a poked finish.
But Valencia scored from the resulting corner, Gabriel heading into an empty net at the back post, with Barca claiming a foul on Marc-Andre Ter Stegen.
Thierry Correia had stepped across the goalkeeper but it was not enough for a free-kick.
Correia could have made it two shortly after but missed the target and instead, Barcelona scored three times in 12 minutes.
First, Valencia's Toni Lato was guilty of a clear handball to prevent Frenkie De Jong tapping in and while Messi missed the penalty, a tame attempt pushed away by Jasper Cillessen, Sergio Busquets did brilliantly to keep the ball alive.
Gabriel blocked Pedri's volley on the line and in the mayhem, Messi reacted fastest to smash in the rebound.
Six minutes later, Barca were in front, Griezmann finishing after De Jong timed his run perfectly to meet Alba's floated cross, only for his header to be palmed by Cillessen into Griezmann's path.
And then Messi scored the best of the lot, winning a free-kick with an excellent touch away from his marker centrally, on the edge of the box, before curling a delightful shot away from Cillessen's left hand and in off the post.
Barcelona looked secure until Soler set up a dramatic finish by thundering in a shot from 30 yards with seven minutes left to play. Valencia pushed, flooding the box and chipping balls forward but ultimately lacking the final chance they craved.
(For more sports news and updates, follow Ahram Online Sports on Twitter at @AO_Sports and on Facebook at AhramOnlineSports.)