Abdi Akgun joined the Marines in August of 2000, fresh out of high school and eager to serve his country. As a Muslim, the attacks of Sept. 11 only steeled his resolve to fight terrorism.
But two years later, when Mr. Akgun was deployed to Iraq with the 26th Marine Expeditionary Unit, the thought of confronting Muslims in battle gave him pause.
He was haunted by the possibility that he might end up killing innocent civilians.
"It's kind of like the Civil War, where brothers fought each other across the Mason-Dixon line," Mr. Akgun, 28, of Lindenhurst, N.Y., who returned from Iraq without ever pulling the trigger. "I don't want to stain my faith, I don't want to stain my fellow Muslims, and I also don't want to stain my country's flag."
Thousands of Muslims have served in the United States military — a legacy that some trace to the First World War. But in the years since Sept. 11, 2001, as the United States has become mired in two wars on Muslim lands, the service of Muslim-Americans is more necessary and more complicated than ever before.
In the aftermath of the shootings at Fort Hood on Thursday by Maj. Nidal Malik Hasan of the Army, a psychiatrist, many Muslim soldiers and their commanders say they fear that the relationship between the military and its Muslim service members will only grow more difficult.
On Sunday, the Army's chief of staff, Gen. George W. Casey Jr., said he worried about a backlash against Muslims in the armed forces and emphasized the military's reliance on those men and women.
"Our diversity, not only in our Army but in our country, is a strength," General Casey said Sunday on "Meet the Press" on NBC. "And as horrific as this tragedy was, if our diversity becomes a casualty, I think that's worse."
It is unclear what might have motivated Major Hasan, who is suspected of killing 13 people. Senior military and law enforcement officials said they had tentatively dismissed the possibility that he was carrying out a terrorist plot. He seems to have been influenced by a mixture of political, religious and psychological factors, the officials said.
Muslim leaders, advocates and military service members have taken pains to denounce the shooting and distance themselves from Major Hasan. They make the point that his violence is no more representative of them than it is of other groups to which he belongs, including Army psychiatrists.
"I don't understand why the Muslim-American community has to take responsibility for him," said Ingrid Mattson, the president of the Islamic Society of North America. "The Army has had at least as much time and opportunity to form and shape this person as the Muslim community."
That sentiment was echoed by Senator Lindsey Graham, Republican of South Carolina, who told "Face the Nation" on CBS that the shooting was "not about his religion — the fact that this man was a Muslim."
Yet also Sunday, Senator Joseph I. Lieberman, independent of Connecticut, announced on "Fox News Sunday" that he would hold hearings to explore whether Major Hasan's actions constituted terrorism.
Whatever his possible motives, the emerging portrait of Major Hasan's life in the military casts light on some of the struggles and frustrations felt by other Muslims in the services. He was disillusioned with the wars in Afghanistan and Iraq, which he perceived to be part of a war on Islam, according to interviews with friends and relatives.
He had been the subject of taunts and felt singled out by his fellow soldiers for being Muslim, friends and relatives said. His uncle in Ramallah, West Bank, Rafik Hamad, said Major Hasan's fellow soldiers had once called him a "camel jockey."
That term, like "haaji" and "raghead," has become a more common part of the lexicon among soldiers on the frontlines of the wars in Iraq and Afghanistan, several Muslim servicemen said in interviews. They spoke about the epithets philosophically, saying they understood using them was a survival tactic to dehumanize the enemy.
But for Muslim soldiers, particularly those who speak Arabic, the struggle to distance themselves from those they fight has often proved more difficult in these wars.
Amjad Khan, who served in the Army for eight years and was deployed to Iraq, said he had tried to get used to the way his fellow soldiers talked about Iraqis.
"It gets to you sometimes," said Mr. Khan, 32, from Queens, who is of Pakistani descent. "But the more personally you take things, the more you're going to have a hard time surviving."
For Mr. Khan, the most difficult part of his wartime service came before he was deployed, when a senior officer found his Islamic faith cause for suspicion.
"He said, 'I have to watch my back because you might go nuts,' " Mr. Khan recalled.
Since Sept. 11, the nation's military has actively recruited Muslim-Americans, eager to have people with linguistic skills and a cultural understanding of the Middle East. Some 3,557 military personnel identify themselves as Muslim among 1.4 million people in the active-duty population, according to official figures. Muslim advocacy groups estimate the number to be far higher, as listing one's religious preference is voluntary.
Many Muslims are drawn to the military for the same reasons as other recruits. In interviews, they cited patriotism, a search for discipline and their dreams of attending college. Some Muslims said they had also enlisted to win new respect in a country where people of their faith have struggled for acceptance.
But if military service has brought approval among non-Muslims, it has sometimes invited a markedly different response among Muslims.
In the South Asian and Arab immigrant communities where the wars in Afghanistan and Iraq are deeply unpopular, Muslim military members have often felt criticized for their service, Muslim chaplains, military members, veterans advocates and others said in interviews.
Some return exhausted and traumatized from their tours, only to hear at their local mosques that they will go to hell for "killing Muslims," said Qaseem A. Uqdah, the executive director of the American Muslim Armed Forces and Veterans Affairs Council.
"Imagine you are 20 years old and you hear you're going to purgatory," Mr. Uqdah said. He argued that Muslim groups must work harder to help their veterans cope with coming home. "We are failing as a community here in America."
During the first gulf war, Muslim scholars in the United States debated whether members of their faith could righteously engage in combat in a Muslim country on behalf of the United States military. The consensus was yes, provided the conflict met the Islamic standard of a "just war."
"In the Koran it says that war is to end the state of oppression and to uplift the oppressed," said Khaled Abou El Fadl, a professor at the law school at the University of California, Los Angeles.
But he and others interviewed said it has been increasingly difficult for Muslims to support the wars in Iraq and Afghanistan, as accounts have emerged of the killing of civilians, the corruption of American-backed local governments, and prisoner abuses like that of the Abu Ghraib scandal .
"Is it an army that defends the oppressed, or have you slipped into becoming the oppressor?" asked Mr. El Fadl, who has counseled Muslims conflicted about enlisting. "People from the military who contact me, that's what I find they're torn up about."
And yet more than 3,500 Muslims have deployed to Iraq and Afghanistan, according to Defense Department figures provided to The Times. As of 2006, some 212 Muslim-American soldiers had been awarded Combat Action Ribbons for their service in Iraq and Afghanistan, and seven had been killed.
Too many Americans overlook the heroic efforts of Arab-Americans in uniform, said Capt. Eric Rahman, 35, an Army reservist who was awarded the Bronze Star for his service in Iraq at the start of the war. He cited the example of Petty Officer Second Class Michael A. Monsoor, a Navy Seal and practicing Christian of Lebanese and Irish descent who was awarded the Medal of Honor after jumping on a grenade and saving at least three team members during a firefight in 2006, in Ramadi, Iraq.
Yet Petty Officer Monsoor will never be remembered like Major Hasan, said Captain Rahman.
Regardless, he said, Muslim- and Arab-Americans are crucial to the military's success in Afghanistan and Iraq.
"Take a look at these conflicts," he said. "We need those skill sets, we need those backgrounds, we need those perspectives."
Eric Schmitt, Damien Cave and Catrina Stewart contributed reporting. Earlier versions of this article misstated the religion and rank of Michael A. Monsoor and the act he performed that earned him the Medal of Honor.
Eric Schmitt, Damien Cave and Catrina Stewart contributed reporting.
Earlier versions of this article misstated the religion and rank of Michael A. Monsoor and the act he performed that earned him the Medal of Honor.