Barca have one foot in next month's final ahead of Tuesday's second leg at Anfield after former Reds striker Luis Suarez gave Barca the lead during a breathless opening 45 minutes before Messi struck twice late on, the second a stunning free-kick and his 600th Barca goal.
Jurgen Klopp could only smile after Messi's curling shot nestled in the top corner but this result was harsh on his side.
They matched Barcelona in the first half, dominated them early in the second and could still have left with an away goal after Messi's deadly double, only for Mohamed Salah to hit the post.
But Messi and Suarez did what they have done all season, their tallies now at 47 and 27 goals respectively in all competitions.
It had been a breathtaking contest befitting two of Europe's most exhilarating teams. The first half was electric, a reel of chances, breaks and blocks, while the second was tense, a tactical battle where Barca dared Liverpool to over-exert.
The comeback will be even tougher for them given Barcelona, with La Liga wrapped up, will surely rest a host of players against Celta Vigo this weekend while Liverpool, a point behind Premier League leaders Manchester City, will have to be at full throttle again away at Newcastle on Saturday.
Messi was already fresh, after playing just over half the La Liga minutes he could have done in April, and he looked sharp early on, weaving through the centre while for Liverpool, the sensational Sadio Mane raced down the left.
The attacks were scintillating but the defending was good too. Andy Robertson scrambled across to block Messi's finish from six yards and moments later it was Sergi Roberto on the slide, preventing Mane from racing clear.
Messi wanted a penalty when the ball jumped up on Joel Matip and Naby Keita went off injured in the 25th minute, replaced by Jordan Henderson.
A minute later came the goal. Arturo Vidal sprayed the ball left to Philippe Coutinho, who cushioned back for Jordi Alba. Alba shaped to cross but instead curved a perfectly weighted pass to the near post, where Suarez nipped in.
Liverpool came again. Mane scampered in behind then flicked the ball round Sergio Busquets. He should have scored too, Henderson's cross finding him free from eight yards but the shot flew over.
Barca took control just as Suarez began to lose it, irked by James Milner barging Messi into the sideboards after the Argentinian had danced past Robertson.
But Liverpool were re-energised at the start of the second half. Marc-Andre ter Stegen pushed away shots from Milner and Mohamed Salah, then held a Milner drive.
Then Messi took the wind out of Liverpool's sails, striking twice in seven minutes. His own run started the first, setting Sergi free to square to Suarez. Off balance, Suarez could only volley against the crossbar but the ball came back for Messi, who chested and finished into an open net.
Two was hard on Liverpool but Messi was not done. The free-kick was central, 30 yards out, and he whipped it over the wall and into the top corner.
Barca were delirious but Liverpool almost grabbed an away goal when a clearance on the line fell kindly for Salah, who hammered against the post and left Liverpool with little hope of making the Madrid final.