BARCELONA, Spain — Cristiano Ronaldo's late goal dealt Barcelona its first loss in 54 home games and put Real Madrid on the cusp of breaking the Catalan giants' three-year hold on the Spanish league crown with a record-setting 2-1 win on Saturday.

Sami Khedira opened with Madrid's league-record 108th goal of the season and Ronaldo sealed the victory with his own league-record 42nd goal moments after Alexis Sanchez leveled for Barcelona.

Madrid's 19th league game without a loss lifted it seven points clear of Barcelona at the top of the standings with just four rounds to go.

After managing only a single win in nine previous games against Barcelona since joining Madrid, coach Jose Mourinho finally guided his team to a long-coveted victory over its fierce rivals on their ground.