One of the men arrested, a 48-year-old Iraqi who had applied for asylum in Germany, was being held on suspicion of associating with a terrorist organization, at least seven cases of human smuggling as well as several cases of falsifying documents, Bavarian police said. He was arrested in Wilhelmshaven, Lower Saxony.
The second suspect, a 36-year-old Syrian national, was arrested in Munich and was being held on suspicion of illegally smuggling several people into the country, police said.
Five other people were detained during searches through seven properties in the two states, they said. No further details were immediately available.
The raids focused on "extremely violent groups" that were supporting the ongoing deadly attacks by illegally collecting donations and smuggling people in and out of Germany, said Guenther Beckstein, interior minister for Bavaria.
"We know that individuals associated with the group traveled from Germany to participate in the attacks in Iraq," Beckstein said.
About 50 police officers carried out the raids, Beckstein said.
Several other alleged members of the Ansar al-Islam organization, which has links to Al Qaeda, have been arrested in Germany. One has been tried and found guilty of supporting the organization; he received a seven-year prison sentence.