Barcelona took the lead just 19 minutes in when Neymar, on his El Clasico debut, found the corner of the net after being played in by Andres Iniesta.
Real pushed hard for an equaliser with Victor Valdes producing fine saves from Sami Khedira and Cristiano Ronaldo.
Ronaldo also had a very good penalty shout waved away before Karim Benzema rattled the crossbar with a stinging drive.
But the win was sealed by Barcelona substitute Sanchez when he beautifully chipped home with 12 minutes remaining.
Real pulled one back in added time when Jese latched onto Ronaldo's ball to fire under Valdes, but it was too little too late for the visitors.
The win means Barcelona maintain their unbeaten start to the season and moves them some six points clear of Real.
Gareth Bale made his second start for Real Madrid but was unable to influence the game and had a frustrating evening, only managing two long-range shots which missed the target, and then picking up a yellow card for a producing a high foot during a challenge with Gerard Pique.
Barca started stronger with Iniesta controlling their play but they did not create many clear chances until Neymar broke the deadlock on 19 minutes.
Sergio Busquets played in Iniesta, who marauded towards goal and then gave the ball to Neymar on the left-hand side of the penalty area.
The Brazilian beat two defenders then shot, the ball deflecting off Dani Carvajal and beyond the reach of Diego Lopez.
Barca could have scored a second goal a couple of minutes later, Lionel Messi racing down the right before shooting a few feet wide of the far post with his left foot.
Real were without shape and without ideas. Their only attempts on goal were long-range efforts from Ronaldo and Bale which were never going on target, although Los Blancos thought they could have had a penalty just before the break.
Ronaldo put in a cross towards Khedira from the left-hand side and Valdes came out to gather but could not keep control of the ball, which may have struck the hand of Barcelona defender Adriano before the goalkeeper collected it again.
Neymar had a chance to double the lead 10 minutes after the break, half volleying a long ball from Iniesta, but Lopez made the save.
Sergio Ramos was withdrawn early in the second half after proving ineffective in his unfamiliar role in midfield and was replaced by Asier Illarramendi.
Real's play improved considerably after the Basque player came on, and a couple of minutes later, created their best chance of the game.
Khedira recovered the ball, Luka Modric played in Ronaldo and the Portuguese's early shot was turned round the post by Valdes.
Benzema replaced Bale with half an hour left and from then on Real had more shape. The Frenchman headed over minutes after coming on and then struck the bar with an effort from outside the area.
Ronaldo was then denied a penalty after going down following a challenge from Javier Mascherano.
Real were looking much likelier to score but a moment of genius from Sanchez killed off the game. The Chilean, who had replaced Cesc Fabregas, ran onto a through ball from Neymar.
Raphael Varane caught up with him but the forward turned around and then released a sublime chip which soared over the outstretched arm of Lopez and dropped into the net.
Dani Alves could have added a third with seven minutes remaining as he approached goal alone, but Lopez stuck out a foot to deny him.
Khedira found himself one-on-one with Valdes late on, but shot straight into the goalkeeper's arms.
Jese, who had replaced Angel Di Maria, salvaged some pride for Real by scoring on the counter, receiving a low cross from Ronaldo and then striking beyond Valdes, who could have done better.