MADRID — Keeping Lionel Messi in check again in what could turn out to be his last Spanish league clásico, Real Madrid continued the impressive run which has put it at the heart of the title race.

Four days after beating Liverpool in the first leg of the Champions League quarterfinals, Madrid defeated Barcelona 2-1 on Saturday to return to the top in Spain.

“We have to enjoy what we've been doing. We got two very good results and it wasn't easy,” Madrid coach Zinedine Zidane said. “Being in the lead won't change anything for us. We have to keep working hard.”

The victory in pouring rain in the Spanish capital left Madrid tied on points with Atlético Madrid, which on Sunday can return to the top when it visits sixth-place Real Betis. Madrid is ahead of its city rival on the head-to-head tiebreaker.

Barcelona, which had been unbeaten in 19 straight league games, stayed one point off the lead.

The 33-year-old Messi, who reached seven straight clásicos without a goal, has his contract with Barcelona ending this season. The Argentina star expressed his desire to leave the Catalan club last year but had the request denied.

Karim Benzema and Toni Kroos scored first-half goals to give Madrid its sixth straight win in all competitions. The defending league champions were coming off a 3-1 win over Liverpool in the Champions League on Tuesday.

“It was a very important victory for us,” Madrid defender Nacho Fernández said after the Barcelona match. “It’s always special to win a clásico, and even more when we are so close together at the top in the fight for the title. You could say today was a final, but there is still a lot left in the league.”

Barcelona got on the board in the second half with a goal by Óscar Mingueza. It nearly equalized with a shot from young substitute Ilaix Moriba that struck the crossbar in the final play of the match.

“We tried until the end but it wasn’t possible. We almost had it in that final play,” Barcelona’s Sergi Roberto said. “We depended on our own results had we won, but now we need to hope that our rivals stumble. We will keep fighting until the very end.”

This was the first time Madrid has taken the league lead since the early rounds of the competition, and it trailed Atlético by 11 points at one stage.

The result ended Barcelona’s six-match winning streak in the league. It had won nine away matches in a row in the competition.

It was an even start at the Alfredo Di Stéfano Stadium in Madrid’s training centre, but the hosts opened the scoring in the 13th minute with Benzema’s superb flicked shot from close range after a low cross by Lucas Vázquez.

The French striker, who has scored 10 goals in his last nine matches, got in front of Barcelona defender Ronald Araújo and flicked the ball toward the net with his back foot. He hadn’t scored against Barcelona in nine consecutive clásicos.

The Catalan club complained of a foul by Vázquez on Messi just moments before the opening goal.

Kroos added to the lead in the 28th from a free kick following a foul on Vinícius Júnior, who was coming off an outstanding performance in Madrid’s win over Liverpool. Kroos shot from just outside the area and the ball was deflected by American defender Sergiño Dest before going into the net.

Madrid almost added to the lead in the 34th when Federico Valverde hit the post after a breakaway led by Vinícius Júnior, who also hit the post in the second half. That was after Barcelona pulled one back in the 60th with a shot from inside the area by Mingueza after a low cross by Jordi Alba.

Madrid played the final minutes a man down after Casemiro was sent off with a second yellow card.

One of Messi's best chances was with a corner kick that curled across the area and hit Madrid goalkeeper Thibaut Courtois’ far post in first-half stoppage time. Messi’s free kick in second-half stoppage time was easily stopped by Courtois.

The visitors complained about being denied a penalty in the final minutes, with Barcelona coach Ronald Koeman saying it was “a clear penalty.”

“I don't know why there is VAR in Spain,” he said.

Madrid got the win despite a depleted defence — with the absence of central defenders Raphael Varane and Sergio Ramos. Barcelona was without the injured Gerard Piqué.

Right back Vázquez, who has been key for Madrid in recent games, had to be replaced due to an injury before halftime.

Barcelona’s next match is the Copa del Rey final against Athletic Bilbao on Saturday, while Madrid travels to England to play Liverpool again in the Champions League on Wednesday.

CALA PLAYS

Juan Cala, who last weekend was accused of racially insulting Valencia defender Mouctar Diakhaby, played from the start in Cádiz’s 1-0 win at Getafe.

Cala denied any wrongdoing and the Spanish league said Friday it had not found evidence to support Diakhaby’s accusation against the Cádiz player.

OTHER RESULTS

Athletic Bilbao was held 0-0 at home by second-to-last Alavés to extend its winless streak to five matches in all competitions. The winless run of last-place Eibar reached 14 matches after a 1-0 home loss to eighth-place Levante.

___

More AP soccer: https://apnews.com/hub/soccer and https://twitter.com/AP_Sports

___

Tales Azzoni on Twitter: http://twitter.com/tazzoni