Pivac has performed the same role at the Scarlets since 2014, masterminding a Guinness PRO12 title last year and securing passage into the semi-finals of the Champions Cup in the same season.
The former New Zealand Police constable has beaten fellow Kiwis Dave Rennie and Scott Robinson to the post, which will be vacated by Gatland after Japan 2019.
Pivac will continue as Scarlets boss until the end of the 2018-19 season and will not officially come under WRU employment until July 2019, with Gatland leading Wales into the World Cup.
"We have secured the best man for the job and we have done so rigorously and decisively to the collective benefit of all involved in Welsh rugby," WRU chief executive Martyn Phillips said.
"Both Wayne and Warren and their coaching teams, our international players, supporters and everyone at the Scarlets now have clarity and there is no underestimating the positive benefit to be gained from having the time to plan properly for the future.
"We have avoided the feeding frenzy that can come at the end of a World Cup year and we have been meticulous in ensuring we have someone of the talent, experience, charisma and rugby acumen to do the very best possible job for Welsh rugby."
Gatland's 12-year reign will make him Wales' longest-serving and most successful head coach.
"I know I'm following in the footsteps of someone who is held in extremely high regard, not only by the Welsh public but also by the players who have played under him," Pivac said.
"I will be doing my best to protect the legacy which Warren Gatland, with the help of those players, will inevitably leave behind.
"It will be an almighty challenge, but one that I'm more than ready for and one that I will relish."