The 50-year-old former Ireland and Wasps coach took up the post in 2007 and has since led Wales to Six Nations Grand Slams in 2008 and 2012, as well as a semi-final place at the 2011 World Cup.
Wales also triumphed at this year’s Six Nations under interim head coach Rob Howley, while Gatland took charge of the British and Irish Lions.
“I am proud and delighted to have been chosen by the Welsh Rugby Union to take charge of Wales teams for the next two Rugby World Cup tournaments,” Gatland said in a statement.
“I have chosen to stay in Wales because of my confidence in the players we have, the coaching structures we have developed and the succession plan of talent we now constantly update.”
Gatland oversaw the Lions’ successful tour of Australia earlier this year, which was their first series win in Australia for 16 years.
He was named UK Coach of the Year at the 2013 UK Coaching Awards and on Sunday won the award for Coach of the Year at the prestigious BBC Sports Personality of the Year awards.
“I know the other major rugby nations take us seriously as opponents who can play excellent rugby and that inspires me to take this group of players even further,” Gatland said.
“There is an incredible amount of hard work ahead but, with the backing of the Welsh Rugby Union, the national squad now has the means to deliver what the Welsh public want.”
He added: “I want to personally thank the WRU and the Welsh rugby public for the fantastic support the national squad enjoys and I aim to return the compliment by devoting all my professional energy to the success of our national team in the years ahead.”
WRU chief executive Roger Lewis praised Gatland for introducing a new degree of professionalism to the Welsh set-up.
“I am pleased and honoured to be able to announce that Warren Gatland will remain head coach of Wales until after the Rugby World Cup in 2019,” he said.
“He has undoubtedly proved that he has the rugby expertise, the passion and the commitment to prepare and inspire our teams to play with the utmost skill and pride for the jersey.”
Gatland, whose contract with Wales had been due to expire after the 2015 World Cup, has expressed an interest in coaching the Lions for a second time when they tour his native New Zealand in 2017.
For that to happen, the WRU would have to grant him a sabbatical, as it did for the tour of Australia this year.