Farhan Abdullahi Hussein said he had met Mr. Muhumed when they worked at the Minneapolis-St. Paul International Airport. Patrick Hogan, an airport spokesman, said a man named Abdifatah Ahmed, an alias Mr. Muhumed had used, had worked there on and off from November 2001 until May 2011, refueling planes and cleaning. (Shirwa Ahmed, an ethnic Somali who blew himself up in a suicide bombing in Somalia in October 2008, also had a job at the airport, pushing passengers in wheelchairs.)

Mr. Hussein, who described Mr. Muhumed as “my best friend,” said Mr. Muhumed used to fume about violence in Libya and Gaza, asking, “Is this fair?” Mr. Muhumed dreamed of joining the Ogaden National Liberation Front, a rebel group trying to carve out an independent state in Ethiopia for ethnic Somalis. When he drank, Mr. Hussein said, Mr. Muhumed’s anger boiled up. Once, at a shopping center popular with Somalis, he even punched a community advocate named Abdi Abdulle who had spoken out against the group’s violent tactics.

“He always wanted to be a freedom fighter,” Mr. Hussein said. “He always wanted to be a hero.”

In April, Mr. Muhumed sent Mr. Hussein a text message saying jihad was his path now. “God gave us jihad,” he wrote. On July 8, he sent a short message celebrating the Islamic holy month. It was the last Mr. Hussein heard from him.

Image Abdirahmaan Muhumed is widely reported to be the second American killed while fighting for ISIS. He dreamed of joining the Ogaden National Liberation Front.

Mr. McCain and Mr. Kastigar grew up in a different world from the towering apartment complexes and rows of Somali barbershops and restaurants that were a backdrop for Mr. Muhumed’s life. But they found a passion for Islam and, ultimately, a path to militancy.

Traces of the friendship between Mr. Kastigar and Mr. McCain are bound up in a few photo albums in Ms. Boada’s home. In one, they wear nearly identical plaid shirts. This is how relatives say they want to remember them: Mr. Kastigar as an energetic, open-minded boy who climbed up walls, and Mr. McCain as someone who made music and fiercely loved his younger sister, Lele.

“They had a similar sense of humor,” Ms. Boada said of the men. In his teenage years, Mr. Kastigar began drinking, smoking marijuana and failing classes, and Ms. Boada said she had seen “a sadness and a darkness” settle over him. He dropped out of high school, got his equivalency diploma and worked at a mortgage office or cutting hair. But he was often unemployed. And a series of arrests compounded his troubles finding work, Ms. Boada said.