Earlier, Antoine Griezmann scored a stunning free-kick as Atletico Madrid compounded a week to forget for Sevilla with a 3-1 at the Vicente Calderon.
Barca needed to come from behind to keep the pressure on Madrid as Eliaquim Mangala headed Valencia in front.
But the on-loan Manchester City defender was sent-off for pulling down Luis Suarez after the Uruguayan had levelled and Messi smashed home the resulting penalty.
Munir El Haddadi briefly levelled for the 10 men before half-time, but Messi and finally Andre Gomes with his first Barca goal sealed the three points.
Madrid still also have a game in hand over their title rivals.
“We created a huge number of chances and deserved to win by a bigger margin,” Barca boss Luis Enrique told Spanish TV station Movistar.
“Against an opponent with very good players we’ve picked up three valuable points.”
Enrique named the same side that beat Paris Saint-Germain 6-1 10 days ago to progress to the Champions League quarter-finals in stunning fashion.
And whilst not matching that drama, there was no shortage of action as Valencia showed up the defensive flaws in Enrique’s new 3-4-3 system.
An action packed final 15 minutes of the first-half saw four goals and a red card.
Barca’s weakness from set-pieces was exposed again a week on from conceding twice from corners in a 2-1 defeat at Deportivo la Coruna when Mangala powered home Dani Parejo’s corner to open the scoring.
The lead lasted just six minutes as Suarez raced onto Neymar’s throw-in to slot into the far corner.
Mangala went from hero to villain as he then pulled down Suarez inside the area to concede a penalty and be sent-off.
Messi beat penalty specialist Diego Alves from the spot.
However, straight from kick-off Barca were caught cold as Jose Gaya teed up Munir El Haddadi to score against his parent club for the second time this season.
The champions still had 45 minutes to make their man advantage count, though, and they did so despite missing a host of chances after the break.
Messi drilled home at Alves’s near post seven minutes into the second period for his 41st goal of the season.
Suarez somehow slotted wide with the goal gaping after Alves had denied Messi his hat-trick, whilst Neymar hit the bar.
But Barca finally put the game to bed a minute from time when Neymar crossed for Gomes to tap home against his old side.
At the Calderon, Griezmann shone for Atletico once more as he teed up Diego Godin’s opener and then struck a stunning free-kick for his 22nd goal of the season.
Koke added Atletico’s third before Joaquin Correa registered a consolation for Sevilla.
Sevilla were dumped out of the Champions League by Atletico’s quarter-final opponents Leicester City on Wednesday and have seen their lead over Atletico in third place in La Liga now whittled down to two points.
A third straight league win moves Diego Simeone’s men seven points clear of Real Sociedad and Villarreal in the battle for fourth.
“Sevilla have had a magnificent season and have been lauded by the press. That highlights even more how well Atletico played,” said Atletico coach Diego Simeone.
And the Atletico fans also celebrated the return of Fernando Torres for the first time since he was knocked unconscious in a sickening head clash at Deportivo la Coruna on March 2.
Defeat realistically ends Sevilla’s already fading shot at the title as they fall eight points behind Real Madrid.
And coach Jorge Sampaoli claimed he has to rediscover the “real Sevilla” during the international break after four games without a win.
“We have come from a very hard blow to take and now we have to find solutions and the real Sevilla.”