Federico Valverde and Jude Bellingham also contributed goals, capitalizing on Barcelona's recent slip, which saw them concede two late goals in a 2-2 draw against Celta Vigo on Saturday.
Madrid has one game in hand over Barcelona, as their match against Valencia was postponed due to the tragic floods in October.
On Wednesday, Madrid will travel to England to take on Premier League leaders Liverpool in the Champions League, aiming to bounce back from a disappointing 3-1 defeat at home to AC Milan in their last match.
The attacking strategy against Leganes proved effective, with Vinícius Júnior operating centrally and Mbappé positioned more on the wing. The French forward ended a four-match goal drought for the club.
“We adjusted their positions, and the team maintained control throughout the match,” said Madrid coach Carlo Ancelotti.
Mbappé expressed his adaptability to play in various roles as assigned by Ancelotti.
“I’ve mentioned from the start that I can play in multiple positions,” Mbappé stated. “My focus is on continuing to perform well and scoring goals.”
Athletic triumphs in Basque derby
Oihan Sancet netted the decisive goal in the 26th minute, leading Athletic Bilbao to a 1-0 victory over Real Sociedad in the Basque Country derby.
This win marked Athletic's fourth consecutive home victory against Sociedad in this rivalry.
The result propelled Athletic to fifth place, while Sociedad remained in 10th.
Villarreal salvages a late draw
In a thrilling encounter, fourth-placed Villarreal managed to equalize in stoppage time, securing a 2-2 draw against sixth-placed Osasuna.
Ante Budimir scored twice for Osasuna within the first 20 minutes. Villarreal, fresh off three consecutive wins across all competitions, responded with a goal from Álex Baena in the 67th minute, followed by a penalty converted by Gerard Moreno three minutes into injury time.
Osasuna, trailing Villarreal by three points, recently suffered a 4-0 defeat against Madrid.
On the same day, Sevilla broke their two-match losing streak in the league by securing a 1-0 victory over Rayo Vallecano, who played the entire second half with ten players following Unai López's dismissal for a serious foul.
Djibril Sow netted the winning goal for Sevilla in the 27th minute.