Carlo Ancelotti's side started poorly at the Power Horse Stadium in Andalusia, and fell behind inside the opening 10 minutes courtesy of a clinical finish from former Manchester United youth player Largie Ramazani.
Madrid struggled to find a way past an inspired Fernando Martinez in the Almeria goal, before Lucas Vazquez, who had an effort ruled out in the first half for offside, eventually pulled Madrid level shortly after the hour mark.
Alaba replaced Ferland Mendy in the 74th minute and with his first touch curled a sumptuous free-kick past Fernando from 25 yards to seal all three points.
Madrid's defence was caught out in just the sixth minute when Ramazani latched onto Inigo Eguaras' superb ball over the top and fired past Thibaut Courtois from just inside the penalty area.
At five minutes and 50 seconds, that was the quickest goal Madrid have conceded on the opening day of a league season since Sergio Aguero scored against them for Atletico Madrid in August 2007.
Los Blancos had a whopping 17 shots before the interval, yet a combination of smart goalkeeping from Fernando and uncharacteristically wasteful finishing from Karim Benzema and Vinicius Junior prevented them from finding a leveller.
Fernando continued to frustrate Madrid after the break, denying Benzema with a fine save, but he was eventually beaten in the 61st minute when Vazquez slammed home after the Almeria goalkeeper had kept out Vinicius' effort.
Alaba then ensured Madrid went back to the capital with maximum points, whipping past a helpless Fernando immediately after entering the action.