The WRU said Lewsey, who retired as a player in 2009 and whose mother is originally from South Wales, would take up his new role at the end of September.
The 2003 World Cup winner worked with Gatland at London Wasps, where he won two European Cups and four national championships.
"We are delighted to have been able to secure someone of the calibre of Josh as our new Head of Rugby," said WRU chief executive Roger Lewis.
"He is passionate about the game and undoubtedly has the experience and determination to make a huge and positive difference for Welsh rugby."
Gatland said he looked forward to working with the 36-year-old, who will oversee rugby in Wales from community to elite level outside the senior international squad.