Wagner, 46, was appointed on a 12-month rolling contract in November 2015.
After a 19th-placed finish in the German's first season, the ex-Borussia Dortmund II coach led the Terriers to fifth last term before beating Reading in the Championship play-off final.
Wagner's assistant Christophe Buehler has also signed a new contract.
Huddersfield's first Premier League game is away to Crystal Palace on Saturday, 12 August.
The club have signed Belgian striker Laurent Depoitre and Australia midfielder Aaron Mooy, for a club-record fee, so far this summer.
Chairman Dean Hoyle told BBC Radio Leeds: "Without David being the coach of this football club last year, Huddersfield Town would not be in the Premier League. He defied all odds.
"The contract is a reward for the loyalty he has given the club."
Huddersfield head coach David Wagner has signed a new two-year deal after guiding the club to the Premier League for the first time.