GARLAND, Tex. — Two men living in Phoenix, including one whom the F.B.I. had linked to Islamist terrorism, were identified Monday by law enforcement officials as the pair who opened fire, and then were killed by a police officer, at an event in Texas where people were invited to present cartoons of the Prophet Muhammad.
One of the men identified as a gunman, Elton Simpson, 30, was convicted in 2011 of lying to F.B.I. agents — denying that he had made plans to travel to Somalia, when in fact, he had. Prosecutors charged that he wanted to go “for the purpose of engaging in violent jihad,” but a judge ruled that the government had not proved that part of the charge, and sentenced him to three years’ probation.
The F.B.I. and the police in Phoenix opened a new investigation several months ago into Mr. Simpson, an American-born convert to Islam, after he began posting on social media about the Islamic State, according to law enforcement officials. As part of that inquiry, the authorities monitored his online postings and occasionally surveilled him, but they had no indication that he planned to launch the attack that occurred Sunday evening in Garland, Tex., the officials said.
The second man identified as a gunman, Nadir Hamid Soofi, 34, had never come under F.B.I. investigation, officials said. Police officers and federal agents raided an apartment in Phoenix early Monday that neighbors identified as Mr. Simpson’s home; public records show Mr. Soofi living in the same apartment complex, but it was not clear if they lived together.
A Facebook page that appears to be Mr. Soofi’s says he graduated from the International School of Islamabad, in Pakistan, in 1998, but a first cousin of his says he was born in the United States. The page also says he attended the University of Utah.
”We’re all devastated,” the cousin, who did not want to be identified, said of Mr. Soofi’s relatives. “We just barely found out just now on CNN. We just need time to grieve as a family.”
About the time of the attack, on a Twitter account with the name “Shariah is Light” that has since been suspended, someone posted using the hashtag #texasattack. The profile picture on the account is of Anwar al-Awlaki, a militant imam killed in a 2011 American drone strike in Yemen, but the Middle East Media Research Institute identified the account as belonging to Mr. Simpson, and said that some of his social media contacts were known supporters of the Islamic State.
Mr. Awlaki had repeatedly called for violence against cartoonists who, in his view, insulted the Prophet Muhammad, writing in Al Qaeda’s Inspire magazine in 2010, “The medicine prescribed by the Messenger of Allah is the execution of those involved.” He also called for the killing of Geert Wilders, one of the speakers at Sunday’s event in Garland.
The “Shariah is Light” Twitter post says that the writer and the man with him have “given bay’ah,” or pledged loyalty, “to Amirul Mu’mineen,” a title, meaning commander of the faithful, that was used by early Muslim rulers and has been claimed by Abu Bakr al-Baghdadi, leader of the Islamic State. “May Allah accept us as mujahideen.”
Asked if the police were aware of that and similar messages, Officer Joe Harn, a Garland police spokesman, said, “We are, but we don’t know that it was those people that put that out.”
Usama Shami, president of the Islamic Community Center of Phoenix, a mosque three miles south of where the men lived, said the two men were friends, and used to come to the mosque. He said neither gave any sign of radicalization.
Mr. Simpson, who had converted in high school, was gregarious and a popular figure among the mosque’s boys, Mr. Shami said, but after his arrest and conviction, he was much more subdued, exhibiting ”just an absence of happiness,” and attended prayers less often. He said Mr. Simpson was briefly married, and asked often about Islam’s rules for things like fasting and courtship.
Mr. Soofi was a quiet man who had moved to Phoenix from Texas, and sometimes attended the mosque with his young son, Mr. Shami said. For a time, Mr. Soofi was an owner of a pizza restaurant called Cleopatra near the mosque, but it went out of business. More recently, he ran a carpet cleaning business, apparently from his apartment.
The two gunmen drove up to the event center in Garland, about 6:50 p.m. Sunday, stepped out of their car holding assault rifles, and began shooting, wounding a security guard, the police said.
The police and F.B.I. agents in Phoenix searched an apartment believed to be Mr. Simpson’s, with much of the Autumn Ridge apartment complex cordoned off through the night. At the same time, F.B.I. agents and technicians were aiding the police in Garland, a city just outside Dallas, in their investigation.
The shooting took place outside the Curtis Culwell Center here, at an event organized by the American Freedom Defense Initiative, a New York-based group that also uses the name Stop Islamization of America.The event included a contest for the best caricature of the Prophet Muhammad, with a $10,000 top prize.
Officials did not give a motive for the attack, but drawings of the prophet are considered offensive in most interpretations of Islam. In January, gunmen in Paris attacked the offices of Charlie Hebdo, a French satirical newspaper known for printing caricatures of the prophet, killing 12 people. The 2005 publication of cartoons of Muhammad in a Danish newspaper prompted demonstrations and drew death threats, and four men were convicted of plotting a retaliatory attack on the newspaper.
Officer Harn said that the police and organizers had planned for months for the heavy security around the event, which about 200 people attended, and that organizers paid $10,000 for added protection. Security included uniformed Garland police and school district officers, SWAT team and bomb squad officers, and representatives of the F.B.I. and the Bureau of Alcohol, Tobacco, Firearms and Explosives.
Mr. Wilders, an anti-Islam leader in the Netherlands for the Party for Freedom, attended the event and delivered a speech. After the attack, he wrote “never surrender to terrorism!” in a Twitter post, and he posted a picture of himself with what he said were SWAT forces taken before the gunmen opened fire.
Pamela Geller, an organizer of the event who runs a website that attacks Islam, said the group decided to hold the event in the Curtis Culwell Center because members had heard that a Muslim group had a conference in the same room after the attack on the Charlie Hebdo office.
Ms. Geller described Sunday’s event as pro-free speech, and said that Muslims had become a “special class” that Americans were no longer allowed to offend.
Officer Harn said the two gunmen stopped their car near the center’s west parking lot entrance, which was blocked by a police car, as the event was drawing to a close. In the police car were a Garland Police traffic officer and a Garland Independent School District security officer, who was unarmed. The officers got out of their car.
“Two men exited the dark color sedan, both of them had assault rifles, and came around the back of the car and started shooting at the police car,” Officer Harn said. He said officers from around the center converged on the scene within seconds, but by then the traffic officer had already killed the gunmen, whose bodies were still on the pavement beside their car well into the day Monday.
He said that the police officer, whom he did not name, returned fire with his pistol, killing both gunmen.
“He did a very good job, and probably saved lives,” Officer Harn said at a news conference Monday. Of the attackers, he said, “I was told they did have body armor; I don’t know the extent of what the body armor was.”
The school district said in a statement that its security officer, Bruce Joiner, was shot in the ankle and taken to a hospital. He was later released.
The police, fearing that the gunmen’s car might contain an explosive device, evacuated not only the center, but also a nearby Hyatt hotel, and several stores and other businesses. They used small explosive charges to open the car trunk and detonate several suspicious objects, before concluding that there was no bomb.
A live video stream of the Garland event on the organizer’s website recorded the moment when the crowd was interrupted by a private security guard in military fatigues, who bounded onto the stage to announce that there had been a shooting outside. “Were the suspects Muslim?” a man shouted.
“I have no idea right now,” said the man in fatigues.
In Phoenix, people living in the Autumn Ridge complex were roused around midnight by the police knocking on their doors, ordering residents to evacuate. Cheryl Klein said she and her wife, Cherielle Rice, stepped out of their apartment, in a building across from Mr. Simpson’s, to find the area swarmed by officers in SWAT gear with assault rifles.
The Phoenix police, Homeland Security agents and F.B.I. agents entered Mr. Simpson’s apartment about 3 a.m. local time, and allowed residents back into their homes about 4:30 a.m.
Neighbors said Mr. Simpson lived on the first floor of one of the buildings on the east side of the complex, a one-bedroom unit that he occasionally shared with roommates.
Ms. Klein said they had seen Mr. Simpson occasionally, doing mundane tasks like taking out the trash, walking to his car or picking up the mail. ”There was never any reason to suspect anything,” she said.