Sergio Ramos scored a late penalty to give Real Madrid a 1-0 victory over Getafe on Thursday, increasing its lead over Barcelona to four points with the Spanish league nearing its end.

Ramos converted the 79th-minute spot kick after Getafe made its first mistake in an otherwise flawless defensive performance to stifle the more talented rivals.

Madrid right back Dani Carvajal raced into the area and cut back around defender Mathías Olivera, who tripped him and gave Ramos the chance to score the winner that boosts his team’s chances of dethroning Barcelona.

Real Madrid's head coach Zinedine Zidane looks at the field during the Spanish La Liga soccer match between Real Madrid and Getafe at the Alfredo di Stefano stadium in Madrid, Spain, Thursday, July 2, 2020. (AP PhotoBernat Armangue)

Real Madrid's head coach Zinedine Zidane looks at the field during the Spanish La Liga soccer match between Real Madrid and Getafe at the Alfredo di Stefano stadium in Madrid, Spain, Thursday, July 2, 2020. (AP PhotoBernat Armangue)

It was the ninth league goal of the season for the Madrid center back.

Madrid has won all six matches since the restart of the league following a three-month stoppage for the coronavirus pandemic. Barcelona, meanwhile, settled for a third draw in four games on Tuesday when it was held 2-2 by Atlético Madrid.

Madrid and Barcelona both have five matches left. Madrid holds the tiebreaker in case of they finish level on points.

Real Madrid's Karim Benzema, right, is challenged by Getafe's Xabier Etxeita during the Spanish La Liga soccer match between Real Madrid and Getafe at the Alfredo di Stefano stadium in Madrid, Spain, Thursday, July 2, 2020. (AP PhotoBernat Armangue)

Real Madrid's Karim Benzema, right, is challenged by Getafe's Xabier Etxeita during the Spanish La Liga soccer match between Real Madrid and Getafe at the Alfredo di Stefano stadium in Madrid, Spain, Thursday, July 2, 2020. (AP PhotoBernat Armangue)

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

Real Madrid's Vinicius Junior reacts after missing a shot during the Spanish La Liga soccer match between Real Madrid and Getafe at the Alfredo di Stefano stadium in Madrid, Spain, Thursday, July 2, 2020. (AP PhotoBernat Armangue)

Real Madrid's Vinicius Junior reacts after missing a shot during the Spanish La Liga soccer match between Real Madrid and Getafe at the Alfredo di Stefano stadium in Madrid, Spain, Thursday, July 2, 2020. (AP PhotoBernat Armangue)

Real Madrid's Sergio Ramos, second left, celebrates after scoring his side's opening goal from a penalty shot during the Spanish La Liga soccer match between Real Madrid and Getafe at the Alfredo di Stefano stadium in Madrid, Spain, Thursday, July 2, 2020. (AP PhotoBernat Armangue)

Real Madrid's Sergio Ramos, second left, celebrates after scoring his side's opening goal from a penalty shot during the Spanish La Liga soccer match between Real Madrid and Getafe at the Alfredo di Stefano stadium in Madrid, Spain, Thursday, July 2, 2020. (AP PhotoBernat Armangue)