Messi scored with a penalty and then a pair of sumptuous free-kicks either side of half-time after Olaza had briefly pulled Celta level.
Madrid: Lionel Messi delivered an incredible dead-ball hat-trick to steer Barcelona to a 4-1 victory over Celta Vigo and ease the pressure on his coach Ernesto Valverde.
Messi scored with a penalty and then a pair of sumptuous free-kicks either side of half-time after Lucas Olaza had briefly pulled Celta level with a free-kick of his own at Camp Nou on Saturday. Sergio Busquets drove home to make sure of the win late on.
A 34th treble in La Liga puts Messi equal with Cristiano Ronaldo, while a much-needed win sends Barca above Real Madrid on goal difference and back to the top of the table at the end of a testing week.
"It is impossible not to depend on Messi, he illuminates everything," said Valverde.
"We depend on him like any team would depend on him. He unlocked the game."
Madrid had briefly claimed first place after continuing their own goal-surge by hammering Eibar 4-0, a game in which Karim Benzema scored twice and Eden Hazard exploded into life.
But while Madrid appear to be hitting their stride, Barcelona's momentum had stalled. After losing to Levante and failing to break down Slavia Prague in the Champions League, scrutiny had again turned on Valverde and his future as Barcelona coach.
Barcelona's disgruntled fans had whistled their team against Slavia in midweek and when Olaza equalised for Celta, that tension and restlessness threatened to return.
Instead, Messi took command, this hat-trick taking his tally to nine goals in seven games, 612 in total for his club.
"Obviously when it's tight we have the advantage of having the best player in the world and the best free-kick taker in the world," said Busquets.
Yet his precision from free-kicks is a skill the 32-year-old has worked on and improved in recent years, his conversion rate currently at four goals from his last seven attempts in the league.
The last time a player scored a hat-trick from set-pieces in La Liga was when Messi himself achieved the same feat in 2012 against Espanyol, albeit with two penalties and one free-kick.
There was good news for Barcelona too in the return of Luis Suarez, who came off the bench after recovering from a calf strain.
Messi scored his penalty in the 23rd minute after Joseph Aidoo had blocked Nelson Semedo's cross with his hand.
It was Messi that conceded the foul for Olaza's curling free-kick that was well-hit enough to beat Marc-Andre ter Stegen, even if the goalkeeper might have been disappointed not to be able to get across.
There was little Celta keeper Ruben Blanco could do about Messi's efforts, the first in stoppage time before the interval and the second three minutes after the restart.
They were almost carbon copies of each other, bending over the wall and nestling in the top right-hand corner.
Celta, under their new coach Oscar Garcia, never looked like mounting a comeback and Busquets put the result beyond doubt with a low shot five minutes from the finish.
Real's players might have been watching on their way home from Ipurua, where they went three up inside 29 minutes, Sergio Ramos scoring a penalty between two Benzema strikes, the second also a spot-kick after Ramos delegated to his teammate. Fede Valverde added a fourth in the second half.
Benzema's double takes him to 157 goals for Real Madrid, above Ferenc Puskas into sixth in the club's all-time list, but his excellent display was trumped by a creative masterclass from Hazard.
"His first half was very impressive," said coach Zinedine Zidane.
"We are happy and he will be a huge player for Madrid, for sure."
- Eden Hazard's vintage performance -
Benzema latched onto Hazard's pass in the 17th minute and after Valverde and Luka Modric missed, the ball spilled back to the Frenchman, who found the corner from an acute angle.
Three minutes later it was two, Hazard the creator again, his feet too quick for Pablo De Blasis, who caught his opponent's right leg. Ramos slid the penalty home.
Hazard sparkled, with a brilliant nutmeg, a 'rabona' cross and too many glides past defenders to count.
Ramos passed on the second Madrid penalty, awarded for a foul on Lucas Vazquez, to allow Benzema to make it three before Valverde had added a fourth, cracking in Modric's pass for his first goal in La Liga.