But they were given a huge scare by Valencia, who took the lead through a header from on-loan Manchester City defender Eliaquim Mangala.
However, the lead lasted just six minutes before Neymar's quick throw-in caught the Valencia defence napping and Luis Suarez raced through to equalise.
A minute before half-time Mangala felled Suarez in the area to earn his marching orders and Messi tucked away the spot-kick.
But the drama did not end there as the 10 men immediately hauled themselves level, with Barca's own player, Munir El Hadidi, doing the damage.
Eight minutes after the break Messi fired the hosts back in front, wriggling past Aymen Abdennour before beating Diego Alves at his near post.
Barca wrapped up a vital victory two minutes from the end when Neymar burst down the left and picked out Andre Gomes for a tap-in.
Who impressed in an eventful encounter at the Camp Nou? Take a look at the gallery above to find out how we rated the players.
Do you agree with our ratings? Who was your man of the match?Let us know in the comments.
Additional reporting by PA