The Barca captain was playing his 767th match for the club across all competitions and opened the scoring as Ronald Koeman's men closed the gap on leaders Atletico Madrid to four points, though there were a few scares along the way.
Messi's sumptuous effort got the ball rolling, as Barcelona's talisman became the first player in LaLiga history to net 20 goals in 13 successive campaigns, and Antoine Griezmann scored an arguably even better effort soon after for his 150th top-flight strike.
A farcical penalty allowed Huesca to pull one back through Rafa Mir, who also inexplicably wasted a remarkable opportunity in the wake of Oscar Mingueza making it 3-1, and Messi finished them off towards the end with another fine goal.
The game was just 13 minutes old when Messi made his mark, effortlessly bending a 20-yard effort around Alvaro Fernandez and into the top-left corner via the crossbar.
Jordi Alba almost made it 2-0 just past the half-hour when his shot from a tight angle was kept out by the frame of the goal, but two minutes later Griezmann picked out the same corner as Messi but from about 10 yards further out – his first league goal since the end of January.
Huesca got a lifeline in bizarre circumstances just before the break, Mir converting a penalty after Marc-Andre ter Stegen was deemed to have fouled him when essentially brushing the striker's shin with his hand, the ball having flashed past both of them.
Barca restored the two-goal lead early in the second period, Mingueza getting his head to a Messi to open his account for the senior side.
Huesca should have reduced the deficit again a few moments later, though, as Mir somehow nudged the ball over the goal from under the crossbar with his chest after latching on to Dani Escriche's header across goal.
Messi capped off a wonderful individual display with his second goal in the 90th minute, receiving Francisco Trincao's pass and elegantly picking out the bottom-left corner from just outside the box.