MADRID (AP)Carlo Ancelotti learned his lesson, and Real Madrid won the ”clasico” on Sunday.

After an embarrassing 4-0 loss at home to Barcelona last season, the Madrid coach made sure he didn’t try anything different with his team this time as Madrid won 3-1 to take the lead of the Spanish league.

It also handed Barcelona another painful blow four days after the Catalan club’s hopes of advancing in the Champions League all but ended.

Ancelotti had used midfielder Luka Modric in the ”false nine” position in attack last season and Barcelona took advantage to rout Madrid at the Santiago Bernabeu Stadium.

”I thought about what happened last season, when I tried something different,” Ancelotti said. ”For this match, I didn’t try to come up with anything, I left the players in their positions and Modric played a spectacular match in midfield.”

Karim Benzema and Federico Valverde scored first-half goals, and Rodrygo added another in second-half stoppage time as the defending champions won the first ”clasico” of the season to move three points ahead of Barcelona in the league standings. The rivals had entered the match tied on points, with Barcelona ahead on goal difference.

It was Madrid’s sixth win in the last seven ”clasicos,” with the only setback the 4-0 result the last time the teams met at the Bernabeu.

Sunday’s defeat was another frustrating setback for Barcelona after it was held 3-3 by Inter Milan at home on Wednesday to be virtually eliminated from the Champions League with two rounds left in its group stage.

”We had our chances, but we are going through a bad moment and nothing goes our way,” Barcelona coach Xavi Hernandez said. ”We need to change this dynamic as soon as possible.”

Barcelona didn’t advance to the knockout stage of the Champions League last season, its first without Lionel Messi, but elimination this time would be extra disappointing considering the club went on a spending spree to boost its squad with players such as Roberto Lewandowski and Raphinha.

Lewandowski, the league’s leading scorer, wasted his greatest chance in the first half, missing high from near the goal line.

Barcelona dominated possession and created scoring chances, but it was Madrid that capitalized on its opportunities and took advantage of Barcelona’s defensive struggles.

”We knew how to suffer when they controlled possession, but we were effective up front and scored the three goals,” Modric said.

Benzema opened the scoring in the 12th minute with a shot from inside the area, off the rebound from a save by goalkeeper Marc-Andre ter Stegen in a one-on-one situation with Vinicius Junior. It was Benzema’s first goal in six matches. He also had a goal disallowed for offside in the second half.

Valverde added to the lead with a low shot from just outside the area in the 35th, with Ferran Torres getting a goal back for the visitors in the 83rd.

Substitute Rodrygo sealed the victory for Madrid by converting a penalty kick in stoppage time after being brought down inside the area.

”We are very disappointed,” Barcelona defender Jules Kounde said. ”We didn’t play a bad match but we made mistakes in transition in the first half and they took advantage.”

Madrid was still without injured goalkeeper Thibaut Courtois, while Barcelona was also hit by injuries and Xavi had to improvise Kounde as a center back.

It was Madrid’s eighth win in nine league matches, with its only setback a 1-1 draw at home against Mallorca in the seventh round.

Barcelona, whose only draw had come in the first round against Rayo Vallecano at home, entered the match having conceded only once in eight league matches.

SOCIEDAD’S MOMENTUM

Real Sociedad won 2-1 at Celta Vigo for its seventh win in a row in all competitions.

Asier Illarramendi and Igor Zubeldia scored a goal in each half for Sociedad, which stayed in fifth place.

Midtable Celta, which scored through veteran striker Iago Aspas in the first half, has lost four of its last five games.

OTHER RESULTS

Real Betis moved to fourth after a 3-1 win over Almeria with a pair of goals by William Carvalho and one by Borja Iglesias.

Espanyol, sitting 13th, beat Valladolid 1-0 with a 78th-minute winner from Joselu. Valladolid stayed just outside the relegation zone.

AP World Cup coverage: https://apnews.com/hub/world-cup and https://twitter.com/AP-Sports

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