Madrid had provisionally moved ahead of its fierce rivals, but Messi kept the defending champions top of the standings with a goal in each half while Xavi Hernandez added another.
Barcelona stayed one point ahead of Madrid with its third straight win.
Levante can keep pace with Barcelona with a victory over Malaga on Sunday.
With 196 goals for Barcelona in all competitions, Messi moved past Laszlo Kubala (194) into sole possession of second place on the club career scoring list, behind only Cesar Rodriguez (235)
Short link: