Okazaki, who scored 10 league goals in the two years he spent at Stuttgart, has also scored 35 goals for Japan.
"We're really pleased that Shinji Okazaki has decided to join us," Mainz coach Thomas Tuchel told Bundesliga.com.
"He's a player with attributes which are very important for the way we play football. He's an absolute team player and is a very versatile attacker, and always very dangerous and potent in front of goal."
Okazaki will stay at Mainz until the summer of 2016.