Alaba's bending shot had Madrid in front for the majority of an end-to-end contest, with Lucas Vazquez making it two in injury-time before Sergio Aguero tapped in his first goal for Barcelona with seconds left.
Barca have now lost a fourth consecutive Clasico for the first time since 1965 and stay a lowly eighth in La Liga, five points behind Madrid, who surge back to the top of the table.
After beating Valencia and winning a crucial Champions League game against Dynamo Kiev this week, it is a fresh set-back for Barca and Koeman, whose future will again come under scrutiny.
Madrid, meanwhile, see their own recovery bolstered, after backing up a thumping win over Shakhtar Donetsk to leave a rocky run in the rear-view mirror.
"These games are always close," said Koeman. "They have their game, we have ours and the details decide the result. It's a shame because we had the opportunities to score."
Madrid coach Carlo Ancelotti said: "We played against a great team, we have suffered, but we were able to cope."
This was the first league meeting between these clubs without either Lionel Messi or Sergio Ramos since 2005 and while there were still veterans on show – Luka Modric, Toni Kroos, Karim Benzema, Gerard Pique and Sergio Busquets among them – it was a Clasico more about the future.
For the first time in 65 years, six players younger than 22 began the game while Gavi, Barcelona’s 17-year-old midfielder, was the youngest Barca starter in a Clasico in almost a century.
The promotion of a duel between Ansu Fati and Vinicius Junior perhaps felt a little forced, but both players have become symbols of hope.
Fati endured one of those games to be expected sometimes of an 18-year-old, with the occasional threat dotted across a quieter display than he would have liked.
Vinicius, though, was electric from the start, a constant thorn in Barcelona’s side, especially in the first half, and instrumental in Alaba’s superb, counter-attacking opener.
Barcelona were the more purposeful early on, setting their stall out by dominating the ball but Madrid were happy to sit deep and posed the greater problems on the break.
Vincius beat Oscar Mingueza with a superb turn through his opponent's legs and as Mingueza scuttled back to recover, Vinicius cut across him and tumbled in the box. The contact was there but minimal.
Not long after, Vinicius was in again and while replays showed he was just offside, Marc-Andre ter Stegen did brilliantly to take him wide and force a finish with defenders back to block.
In between, Barca were controlling the ball, their more patient approach yielding a golden opportunity for Sergino Dest, the American more accustomed to right back than right wing, who blazed over from six yards after Memphis Depay slid across.
Madrid made Barcelona pay in the 32nd minute with a wonderful goal. Alaba tackled Depay on the edge of his own box and kept going, at first wanting it down the line from Vinicius, who instead switched forward to Rodrygo.
This time Alaba would get it back, his space opened up by the curving run of Benzema, and from the edge of the area he swerved the ball inside the far post.
Barcelona grew in confidence before the hour but Madrid survived and threatened a second as Luka Modric’s bending effort was blocked and then Modric teed up Benzema, who volleyed at Ter Stegen.
The game had become stretched and there was a dramatic finish.
Pique wanted a penalty when he was prevented from finishing in the box and on the counter-attack, Madrid made it two, Marco Asensio’s shot swept in by the sliding Vazquez in the 93rd minute.
There was still time for an Aguero goal in the 97th, a sharp finish from Dest’s cross, but not for a comeback. (AFP)