A topsy-turvy 90 minutes saw Valencia take the lead at Camp Nou before coming from behind to level at 2-2, but Eliaquim Mangala's red card in the latter stages of the first period made it an uphill struggle for the visitors in the second 45 minutes.
The result has seen Barcelona move to within two points of La Liga leaders Real Madrid, who still have a game in hand, while Valencia remain in 14th position in the table after suffering their 14th league defeat of the campaign.
Barcelona boss Luis Enrique made five changes to the team that started last weekend's 2-1 defeat at Deportivo La Coruna, with Samuel Umtiti, Rafinha, Ivan Rakitic, Andres Iniesta and Neymar all returning to the XI.
As for Valencia, head coach Voro made just one change to the side that drew at home to Sporting Gijon last time out as club captain Enzo Perez returned from suspension, but Nani was once again absent through injury. There was also a start for on-loan Barcelona attacker Munir El-Haddadi against his parent club.
Barcelona came close to making the breakthrough inside the opening three minutes when Luis Suarez broke into the Valencia box before delivering a low cross towards Messi, but Jose Gaya was on hand to clear with a vital piece of defensive work.
The visitors then threatened down the other end when Joao Cancelo's pace took him into a dangerous position inside the Barcelona box, but the Portuguese international could not lift his head and pick out teammate Fabian Orellana, who would have had a simple tap-in at the far post.
The chances continued to arrive as Luis Suarez tested Valencia goalkeeper Diego Alves with a low strike in the eighth minute of action, before Los Che full-back Gaya cleared a close-range Messi effort off the goal-line after Luis Suarez had put one on a plate for the Argentine.
Valencia were next to come close in the 19th minute when a poor defensive clearance from Gerard Pique opened up a shooting chance for Carlos Soler, but Barcelona goalkeeper Marc-Andre ter Stegen was on hand with a smart save.
The home side had a big shout for a penalty in the 26th minute when Neymar went down inside the opposition box under a challenge from Cancelo, but the referee was not interested as a feisty and open match continued to entertain.
Ter Stegen produced another smart save to prevent Munir from firing Valencia ahead in the 29th minute, but the German goalkeeper could do nothing from the resulting corner as Mangala rose highest inside the box to plant a brilliant header into the bottom corner as Los Che took the lead at Camp Nou.
Barcelona were level six minutes later, however, when a long throw-in from Neymar released Luis Suarez inside the Valencia box and the Uruguay international settled before slipping the ball past the onrushing Alves.
It went from bad to worse for the away side in the final stages of the first period when Mangala was handed a straight red card for pulling Luis Suarez to the deck inside the Valencia box, and Messi stepped forward to send his penalty past Alves as Barcelona looked to take a 2-1 lead into the half-time break.
Voro's side had other ideas, however, and incredibly levelled the scores at 2-2 less than 60 seconds later when Gaya found room down the left before squaring the ball into Munir, who netted against his parent club once again.
As expected, Valencia made a defensive change at the interval as Aymen Abdennour replaced Orellana, with the 27-year-old slotting into the centre-back spot that Mangala vacated following his red card.
Barcelona had a golden chance to regain the lead in the 51st minute when Messi released Neymar inside the Valencia box, but the Brazilian could not find a route past Alves, who made an outstanding save.
The home side were ahead less than 60 seconds later, however, as Messi somehow found a yard of space inside a crowded area before smashing the ball past Alves at his near post.
Munir should have made it 3-3 just before the hour when the on-loan Barcelona forward again broke clear of the home side's defence, but Pique just about did enough to deny the 21-year-old a shot on goal.
Barcelona might have scored their fourth of the night in the 62nd minute when Messi freed Luis Suarez with a wonderful ball inside the Valencia box, but the striker could only hit the side-netting as the visitors just about remained in the argument.
Rafinha was next to come close for the Catalan giants 20 minutes from time after Messi had found the Brazilian, but the midfielder's effort was straight down the throat of Alves, before Luis Suarez curled one over the crossbar moments later.
Luis Suarez had another super chance in the 72nd minute when Alves palmed a Messi strike straight into the path of the centre-forward, but he somehow bobbled the ball wide of the far post as it remained 3-2 to the home side.
It was then Neymar's turn to come close as the Brazilian struck the frame of the Valencia goal with a spectacular free kick approaching the final 10 minutes of action.
Simone Zaza and Zakaria Bakkali were both introduced for Valencia in the latter stages as the away side looked to respond once again, but it was Barcelona that continued to look the more likely to add to the scoring at Camp Nou.
Indeed, there was to be some icing on the cake for the Catalan giants as Andre Gomes converted a low Neymar cross in the 89th minute to ensure that Enrique's side closed the gap on league leaders Real Madrid to just two points.
Next up for title-chasing Barcelona is a trip to Granada after the international break, while Valencia will look to return to winning ways when they host Deportivo La Coruna on April 2.