The men drove up to the Curtis Culwell Center in Garland on Sunday night as the event was coming to an end and shot at the security officer, the City of Garland said in a statement. Garland police officers returned fire, killing the men.
Garland police spokesman Joe Harn said it was not immediately clear whether the shooting was connected to the contest hosted by the New York-based American Freedom Defense Initiative that would award $10,000 for the best cartoon depicting the Prophet Muhammad.
PHOTOS: Shooting outside Muhammad cartoon event in Garland
Harn said authorities were searching the gunmen's vehicle for explosives.
"Because of the situation of what was going on today and the history of what we've been told has happened at other events like this, we are considering their car (is) possibly containing a bomb," he said at a news conference late Sunday.
According to mainstream Islamic tradition, any physical depiction of the Prophet Muhammad - even a respectful one - is considered blasphemous. Drawings similar to those featured at the Texas event have sparked violence around the world.
The wounded security officer, who was unarmed, worked for the Garland Independent School District, Harn said. He was treated and released from a local hospital.
The Curtis Culwell Center, the public events space that hosted the event and is owned by the school district, was evacuated after the shooting, as were some surrounding businesses. The evacuation was lifted several hours later but a large area around the center remained cordoned off late into the night.
Police helicopters circled overhead as bomb squads worked on the car. Harn said the bodies of the gunmen, whose identities have not been released, were not immediately taken from the scene because they were too close to the car. He said they would be removed once the car was cleared.
Harn said the district hires security for events at its facilities, but noted that additional security was hired for Sunday's event. The sponsoring group has said it paid $10,000 for off-duty police officers and other private security.
Harn said the city had not received any credible threats before the shooting.
Texas Gov. Greg Abbott said state officials are investigating, and Dallas FBI spokeswoman Katherine Chaumont said that agency is providing investigative and bomb technician assistance.
The event featured speeches by American Freedom Defense Initiative president Pamela Geller and Geert Wilders, a Dutch lawmaker known for his outspoken criticism of Islam. Wilders received several standing ovations from the crowd and left immediately after his speech.
Wilders, who has advocated closing Dutch doors to migrants from the Islamic world for a decade, has lived under round-the-clock police protection since 2004.
After the shooting, authorities escorted about 75 contest attendees to another room in the conference center, where a woman held up an American flag, and the crowd sang "God Bless America."
The group was then taken to a separate location, where they were held for about two hours where they were questioned by FBI agents then released.
Johnny Roby of Oklahoma City, Oklahoma, told the Associated Press he was outside the building when he heard around about 20 shots that appeared to come from a passing car.
Roby said he then heard two single shots. He said he heard officers yell that they had the car before he was sent inside the building.
Geller told the AP before Sunday's event that she planned the contest to make a stand for free speech in response to outcries and violence over drawings of Muhammad. She said in a statement issued after the shooting that it showed how "needed our event really was."
In January, 12 people were killed by gunmen in an attack against the Paris office of the satirical newspaper Charlie Hebdo, which had lampooned Islam and other religions and used depictions of Muhammad. Another deadly shooting occurred the following month at a free speech event in Copenhagen featuring an artist who had caricatured the prophet.
Tens of thousands of people rallied around the world to honor the victims and defend the freedom of expression following those shootings.
Geller's group is known for mounting a campaign against the building of an Islamic center blocks from the World Trade Center site and for buying advertising space in cities across the U.S. criticizing Islam.
When a Chicago-based nonprofit held a January fundraiser in Garland designed to help Muslims combat negative depictions of their faith, Geller spearheaded about 1,000 picketers at the event. One chanted: "Go back to your own countries! We don't want you here!" Others held signs with messages such as, "Insult those who behead others," an apparent reference to recent beheadings by the militant group Islamic State.