Sunday's attack took place shortly before 7 p.m. in a parking lot of the Curtis Culwell Center, an indoor arena in the suburb of Garland, northeast of Dallas. Geert Wilders, a polarizing Dutch politician and anti-Islamic campaigner who is on an al Qaeda hit list, was among the speakers at the event.
Police said they had not immediately determined the identity of the two gunmen or whether they were linked to critics of the event who had branded it anti-Islamic.
As a precaution, a police bomb squad was called to check the suspects' car for possible explosives, and the immediate vicinity of the Culwell Center was evacuated, city police spokesman Joe Harn told Reuters.
The exhibit was organized by Pamela Geller, president of the American Freedom Defense Initiative (AFDI). Her organization, which is described by the Southern Poverty Law Center as a hate group, has sponsored anti-Islamic advertising campaigns in transit systems across the country.
Organizers of the "Muhammad Art Exhibit and Contest" said the event was to promote freedom of expression. They offered a $10,000 prize for the best artwork or cartoon depicting the Prophet, as well as a $2,500 "People's Choice Award."
Depictions of the Prophet Mohammad are viewed as offensive in Islam, and Western art that portrays the Prophet has sometimes angered Muslims and provoked threats from radicals. Charlie Hebdo, the French magazine attacked in January, had printed cartoons of the Prophet.
In Sunday's incident, the two suspects drove up to the building in a car as the event was coming to an end, and opened fire with automatic rifles at an unarmed security officer, striking him in the leg, police and city officials said.
Garland police officers who were on the scene assisting with security returned fire, killing both suspects, Harn said. He told reporters the shooting incident lasted seconds.
The security officer was treated at a local hospital and later released, Harn said. No one else was injured.
Most of the around 200 people attending the event were still inside the arena when the violence unfolded and were unaware of what had happened until police came into the building and advised everyone to remain indoors because of a shooting.
"The first suspect was shot immediately. The second suspect was shot and wounded – reached for his backpack. Of course officers not knowing what was in the backpack, shot him again. He was killed," Garland Mayor Douglas Athas told CNN.
The mayor said the city permitted the event even though officials knew its inflammatory theme could provoke an attack.
"There was concern, which is why we had heightened security in the area, but we all swear to uphold the Constitution: free speech, free assembly and in this case perhaps, free religion," Athas said. "So in this case they were free to use the building."
He said the school district that owns the building had posted extra security officers at the venue, and the city of Garland also had a number of security and SWAT (special weapons and tactics) teams in the area.