Celta Vigo started well but fell behind when Aidoo handled Junior Firpo’s cross and Messi slotted home from the spot.
The visitors equalised with a perfect free-kick from Lucas Olaza, after Messi fouled Pape Cheikh on the edge of his own area.
However, Barcelona’s talisman made amends just before halftime by curling home a free-kick at the other end after Arthur was fouled.
Messi then completed his hat-trick three minutes into the second half with an identical free-kick which left Celta goalkeeper Ruben Blanco with no chance.
Sergio Busquets rounded off a comfortable victory with a low drive at the near post after 85 minutes.
Barcelona and Real are top of the table on 25 points from 12 matches, ahead of Real Sociedad on 23, who have played 13.
Real had moved top earlier in the day after thrashing Eibar 4-0 at a rainy Ipurua.
Karim Benzema, Sergio Ramos and Fede Valverde struck as Zinedine Zidane’s side ran riot. French striker Benzema broke the deadlock after 17 minutes.
The forward fired home after the ball rebounded to him in the box as Madrid forced the Basque side back.
Captain Ramos rolled home from the penalty spot after Eden Hazard was fouled, before Benzema converted another spot-kick when Cote brought down Lucas Vazquez.
Valverde curled home a fourth after the break after being teed up by Luka Modric as Madrid sealed a comfortable victory, finding the goals they lacked in last weekend’s goalless draw with Real Betis.
Real coach Zinedine Zidane praised the ruthlessness of his side.
“For a coach to see all the players so focused is great. They all have real quality and showed that today,” the Frenchman said.
Valencia beat Granada 2-0 to pull level with their opponents on 20 points and move up to seventh.
Alaves thrashed mid-table Real Valladolid 3-0 with goals from Joselu, Tomas Pina and Lucas Perez.