Nadir Soofi, a gunman shot dead after opening fire at a Texas exhibit of caricatures of the Prophet Muhammad, was a popular schoolboy in Pakistan but struggled to adjust to the United States after moving there as a teen, friends said on Tuesday.

Soofi's story appeared to trace a familiar arc for some Western Islamists — disappointment, alienation, and a search for belonging that ended with the embrace of militancy.

That is what police say inspired Soofi and his roommate, Elton Simpson, to attack the exhibit and contest to draw Prophet Muhammad cartoons on Sunday.