Bayern says Ulreich has a three-year contract.
Ulreich is expected to take the place of Pepe Reina, who is reportedly preparing to leave the club before the new season.
The 26-year-old Ulreich has plenty of experience, having played 220 matches for Stuttgart, including 27 in the Europa League. Stuttgart barely avoided relegation last season.
Ulreich says it was “time for something new” after many years in Stuttgart, where he made his Bundesliga debut in 2008.
Neither Bayern nor Stuttgart disclosed the transfer sum.