The 21-year-old confirmed earlier this week that he would be leaving Werder after just one season having triggered a clause in his contract which made him available on a free transfer.
The likes of Hoffenheim, RB Leipzig and Borussia Dortmund had been linked with a move for the Germany international, but Bayern have won the race and Gnabry will officially join on a three-year deal when the transfer window reopens.
"It is a great honour to be part of FC Bayern. Before me lies an exciting time, which I am very much looking forward to," Gnabry told the club's official website.
Bayern chairman Karl-Heinz Rummenigge added: "We are delighted to see another young German national player in FC Bayern in Serge Gnabry. Serge has developed very well in Bremen."
Gnabry, who struggled to break into the first team at Arsenal, scored 11 goals in 27 appearances for Werder during his only season at the club.