Messi curled home a fantastic 30-yard free-kick before latching onto Philippe Coutinho’s through ball to make it 2-0.
Nabil el Zhar pulled one back but Messi scored from Ousmane Dembele’s pass to complete a 45th career hat-trick.
Barca, who are seven games from an unbeaten La Liga season, are now 12 points above Atletico Madrid.
They equalled Real Sociedad’s record of 38 matches unbeaten across 1978-79 and 1979-80 – and are now targeting becoming the first team to go unbeaten in a 38-game season in Spain’s top flight.
Atletico can narrow the gap back to nine points when they visit Real Madrid on Sunday (15:15 BST).
Barca are next in action on Wednesday at Roma in the Champions League quarter-final second leg, defending a 4-1 advantage from the first leg at the Nou Camp.
Messi’s free-kick means he is the first player to score from outside the box in six consecutive La Liga games since at least 2003-04 – when Opta started recording detailed statistics.