The 56-year-old signed a three year contract with the Deutscher Fussball-Bund - the German football association - and will begin after next month’s European championships.
He will succeed Joachim Löw with whom he won the World Cup as an assistant in 2014.
"Everything happened surprisingly quickly for me and I am happy to be national team coach from the autumn," Flick said in a statement.
"My joy is great because I see the quality of the players, especially the young ones, in Germany. So we have every reason to approach the next tournaments with optimism."
Success
Flick’s stock rose exponentially during 18 months as Bayern Munich coach.
He took over an ailing animal in November 2019 and transformed it into a title-winning monster.
From June 2020, Bayern won their eighth consecutive Bundesliga, the DFB Pokal, the Uefa Champions League, the European Super Cup and the German Super Cup.
At the start of 2021, they added the Club World Cup to the haul.
Though they failed to defend their Champions League title - losing in the last eight to Paris Saint-Germain - they retained the Bundesliga.
Favourite
Once Löw announced his departure, Flick was one of the favourites to take over.
Not only did he boast a decade of working within the DFB as a coach and sporting director, he was having very public spats with Bayern's sporting director Hasan Salihamidzic over player recruitment.
"Hansi was from the start at the very top our my wish list," said national team director Oliver Bierhoff.
"It’s wonderful that Hansi is returning to the DFB as head coach," added DFB vice president.
"Since his highly successful time here, he has continued to develop extraordinarily as both a person and a coach, as shown by his fantastic success with FC Bayern."
Flick's first game in charge of Die Mannschaft - as the national team is nicknamed - will be a 2022 World Cup qualifier in Liechtenstein on 2 September.
His first home game follows three days later against Armenia and will be followed by a trip to Iceland on 8 September.