BARCELONA, Spain (AP) — Lionel Messi scored a record-setting hat trick to help Barcelona rout Rayo Vallecano 6-1 and take the lead of the Spanish league on Sunday.

Messi's three second-half goals completed his 32nd career treble in all competitions for Barcelona, breaking a Spanish record held by former Athletic Bilbao great Telmo Zarra with 31. Messi also became the all-time leader in hat tricks scored in the league with 24, one more than rival Real Madrid star Cristiano Ronaldo.

The Argentina forward made sure Barcelona capitalized on Madrid's latest slip — a 1-0 loss to Athletic Bilbao on Saturday — to move one point ahead at the top of the table with the fierce rivals set to meet in the Catalan capital in two weeks.

Luis Suarez got Barcelona going in the sixth minute at Camp Nou with his first of two goals before Gerard Pique tapped in a ball Jordi Alba had headed off the post four minutes after halftime.

Messi's treble in a 13-minute span came after he missed his second penalty in as many weeks following Roberto "Tito" Triguero's sending off for a second booking. But the referee ordered the spot kick to be repeated because a Rayo player had entered the box, and the Argentine wasn't denied a second time.

He then struck twice more to equal Ronaldo's competition-leading tally of 30 goals in 26 rounds. Ronaldo had once looked set to run away with the league's individual scoring title when he led Messi by a margin of 25-13 goals through 15 rounds.

The three goals took Messi's season tally overall to 41 goals in 38 games, as he reached the 40-goal mark for a sixth consecutive season.

Barcelona also finished with 10 men when Dani Alves saw red for fouling Alberto Bueno, who converted the late penalty.

Suarez scored again in stoppage time for his sixth goal in his last four appearances, as the former Liverpool striker finds his stride in time for crucial upcoming matches against Madrid in the league, Manchester City in the Champions League and a Copa del Rey final against Athletic Bilbao.

"Suarez plays well with Messi and is giving us more and more," said Barcelona coach Luis Enrique. "It's clear they have a special connection. When you put players of their talent together it gives us many more options in attack."

Also, Villarreal strengthened its hold on sixth place and a Europa League berth by beating ninth-place Celta Vigo 4-1 at home through goals by Giovani Dos Santos, Matteo Musacchio, Luciano Vietto and Gerard Moreno.

And his side paid a heavy price for playing a high defensive line, which often left its goalkeeper Cristian Alvarez to act as a sweeper and fend for himself.

Messi had a spot kick saved by Alvarez a week after City goalkeeper Joe Hart blocked his try, but this time he was able to retake the penalty and drove in Barcelona's third goal in the 56th.

Messi was well placed to finish off Alvarez's save of Suarez's shot in the 62nd, and six minutes later he dribbled past the goalkeeper to roll in his third.

Barcelona's big win came a day after Madrid's defeat at Bilbao, which followed a home draw against Villarreal.

Later, third-place Atletico Madrid hosts fourth-place Valencia.

SI Apps
We've Got Apps Too
Get expert analysis, unrivaled access, and the award-winning storytelling only SI can provide - from Peter King, Tom Verducci, Lee Jenkins, Seth Davis, and more - delivered straight to you, along with up-to-the-minute news and live scores.