The 21-year-old has established himself as Bayern's first-choice left-back and one of the league's rising stars.
The Austria international, whose previous deal was due to run out in 2015, said on the club website: "I am very, very happy."
Sporting director Matthias Sammer added: "At 21 you have not yet matured. The signal from David, to carry on here with us, is very important."
Alaba is already a two-time Bundesliga and DFB-Pokal winner as well as a Champions League winner.
Chairman Karl-Heinz Rummenigge is impressed with his progress.
"He developed wonderfully on the pitch," he said. "The coach (Pep Guardiola) is very happy, we are very happy. David has made a major contribution to ensuring that we have had many successes this year."
Alaba, who has 30 caps for Austria, made his Bayern debut aged 17 in February 2010.