Investigators say 18-year-old repeatedly stated a hatred of Turks and Arabs.
The incident comes as the country remains on high alert after four violent attacks in a week.
Authorities found a video on the attacker's phone in support of the radical group.
Bavaria's top security official suggested the 27-year-old had an "Islamist" motive.
Security agencies continue to search for anyone linked to attacks in Paris and Brussels.
Authorities arrest two Algerians with suspected links to militant group as search for two more continues.
It is not yet known whether the arrests are related to terror plots or organised crime.
12 homes were raided as well as a mosque thought to be linked to radical Islamic Salafists.
Militants connected with radical group Islamic State were planning to behead a member of the public in Australia, Prime Minister Tony Abbott has said