CHIOS, Greece — Hani Alkhalaf had just fallen asleep at an overcrowded detention camp for migrants on this Greek island when angry shouts jolted him awake. As he rose from the dingy floor, a barrage of stones rained down on the flimsy plastic container where he and 14 other asylum seekers, mostly Syrians like him, were sheltered.

Panicked, the women and children ran into a corner and tried to shield themselves as a mob of Afghan migrants beat on the barricaded door, he recalled later. Tensions had been simmering for days between Afghans and Syrians in the camp, but by midnight last Friday, they had exploded into a riot.

“Afghans are angry because Syrians can get asylum in Europe, and they can’t,” said Mr. Alkhalaf, who left the Syrian capital, Damascus, to escape conflict, only to find himself facing violence after making a perilous journey to Europe. “They are going to have to be deported to Turkey, so they are making trouble.”