Lionel Messi scored four goals that took him past the 40-goal mark for a third straight season and guided Barcelona to a 5-1 victory over Valencia.

Barça had to come from behind to stay within 10 points of the leaders Real Madrid, after they trailed within 10 minutes at the Camp Nou through Pablo Piatti's goal. But Messi equalised after 22 minutes and he put the champions in front seven minutes later when the goalkeeper Diego Alves failed to hold his shot.

Messi powered a loose ball beyond Alves for his third in the 76th minute, before lobbing the Brazilian goalkeeper in the 85th to mark his 200th game for Barcelona with his 146th goal. Xavi Hernández scored the fifth Barcelona goal in stoppage time.

"The team played an incredible game. The important part of the season is coming and we have to continue in this way," said Messi.