Karim Benzema scored twice in between goals from Gareth Bale and Sergio Ramos to secure the three points, despite a scare when Guido Carrillo made it 1-1 when he fired a penalty past debutant goalkeeper Thibaut Courtois.
Bale stretched his scoring run to seven consecutive league games 17 minutes in, volleying in Dani Carvajal's header from 12 yards out, although goalkeeper Ivan Cuellar should arguably have done better to keep it out.
Leganes went into the game having failed to win any of their 10 Madrid derbies in LaLiga, but they snatched an equaliser 24 minutes in when Carrillo swept home from the penalty spot after Casemiro tripped Javier Eraso.
The goal seemed to disrupt Madrid's rhythm, although they continued to have nearly 80 per cent of the possession, with Cuellar denying Benzema's volley in one of the few chances before half-time.
But Benzema put them back ahead three minutes after the break with a well-aimed header, the goal eventually given after a VAR review overturned a foul awarded against the striker.
There was no doubt about Benzema's second, though, as he collected Marcelo's pass, played a one-two with Luka Modric and rifled a shot into the bottom-left corner from the edge of the area.
Captain Ramos added a fourth from the penalty spot 66 minutes in to move the European champions onto nine points and send them into the international break in a positive mood.
Our 2017/18 UEFA award winners!— Real Madrid C.F. (@realmadriden) September 1, 2018
Goalkeeper of the Season (@NavasKeylor)
Defender of the Season (@SergioRamos)
Midfielder of the Season (@lukamodric10)
Player of the Year (@lukamodric10) pic.twitter.com/DFQtwq90ME
What does it mean: Bale and Benzema showing there is no need for Ronaldo replacement
Mariano Diaz was not quite the new number seven Madrid fans had in mind after Cristiano Ronaldo joined Juventus, but the Portugal star will not be missed too much if Bale and Benzema can continue this form.
Bale is on his best goalscoring run ever in LaLiga and Benzema is looking as sharp as he has in the last three seasons. If the duo have been liberated by Ronaldo leaving the team, they are taking full advantage.
It is far too early to predict the title race's trajectory, but Madrid appear to be more readily equipped than Atletico Madrid to challenge Barcelona, even though only 16 days have passed since they lost the UEFA Super Cup to their city rivals.
Pat on the back: Benzema lays down challenge to Mariano
Mariano was brought back to the club as competition for Benzema, but, on this evidence, he will find it tough to dislodge the Frenchman.
Benzema's first was a precise header, with his second a powerful finish following an excellent team move. It was quite the showcase of the all-round ability he still possesses, and a timely reminder to his detractors of what he has to offer.
Boot up the backside: Casemiro almost costs Los Blancos
Madrid were largely excellent, particularly in the second half, but Casemiro could have cost his side with a clumsy challenge to concede the penalty.
He also had the lowest passing accuracy (86.3 per cent) of any of Madrid's midfielders. In fact, only Benzema had a lower pass completion rate.
Madrid return from the international break for a tricky trip to San Mames to take on Athletic Bilbao on September 15. Leganes host Villarreal the following day.