Chilean midfielder Arturo Vidal struck the only goal of the game in the 15th minute, firing into the net off the post after being played in by Messi, who now has 20 assists in the league to go with his 22 goals.
Yet Barca failed to build on their early advantage and were forced to grind out the victory in the second half as Valladolid took the game to them.
The win took second-placed Barca on to 79 points after 36 games, one behind Real Madrid who can restore their four-point advantage when they visit Granada on Monday.
Should Real beat Granada and follow that with victory at home to Villarreal on Thursday, they will be crowned champions for the first time since 2017.
Valladolid meanwhile are 14th on 39, seven above the relegation zone.
"It was a very difficult game against a team who know how to play well and did just that today. The hot conditions also complicated things for us but I'm pleased we won," said match-winner Vidal.
"We knew that we'd have to work very hard and wouldn't be able to maintain our pace throughout, we know we want to improve but we've kept ourselves in the title race that's the important thing."
Valladolid's Turkish forward Enes Unal forced Barca's goalkeeper Marc-Andre ter Stegen to stretch across goal and tip away his shot, moments after Kike Perez had missed the target from inside the area as the home side made a lively start after the break.
Ter Stegen was forced into action once again in added time to repel a shot from former Barca forward Sandro Ramirez as the visitors were left begging for the final whistle to arrive.
The scrappy victory followed Wednesday's narrow derby win over Espanyol and their mesmerising 4-1 thrashing over Villarreal last week feels like an anomaly in a downward trend of performances from Quique Setien's side.