More than 30 police joined the raids on ten rooms in several accommodation facilities in the towns of Nagold and Wildberg in the southwestern state of Baden-Wurttemberg, said police.
"The Afghan asylum seekers are suspected of having raped a 17-year-old Iranian asylum seeker several times and of having filmed the acts," police and prosecutors said in a brief joint statement.
Germany took in almost 900,000 asylum seekers last year - about half from conflict-torn Syria, Iraq and Afghanistan - and put them up in shelters countrywide, including hostels, shops, sports gyms and army barracks.
Tensions have at times flared in the often overcrowded facilities, where refugees typically have little space or privacy and face the frustration of months-long waits to have their cases heard.
While some shelters have seen mass brawls between members of different national, ethnic and religious groups, in others women and children have faced a heightened threat of sexual abuse, say aid workers.
Police though have not explained the background to the rape or how the suspects knew the teenager.