WASHINGTON — Counterterrorism officials on Tuesday were studying the electronic trails left by two men killed by a police officer as they shot at a Prophet Muhammad cartoon contest in Texas, looking for any direct ties to the Islamic State extremist group in Syria. The group praised the gunmen in a statement as “soldiers of the caliphate,” the unified Muslim land that it purports to be building.

But any secret ties that officials might find may be less important than the public exchanges of messages on Twitter by one of the gunmen, Elton Simpson, in the weeks before the attack. Mr. Simpson, a convert to Islam with a long history of extremism, regularly traded calls for violence on Twitter with Islamic State fighters and supporters, as well as avowed enemies of Pamela Geller, the organizer of the cartoon contest.

His Twitter contacts included Junaid Hussain, a British fighter with the Islamic State in Syria known as Abu Hussain al-Britani, and Mohamed Abdullahi Hassan, a Somali-American now in Somalia who uses the name Mujahid Miski and frequently promotes the Islamic State. Both men called for violence, and Mr. Hassan had suggested the Texas event as a possible target.

On April 23, 10 days before the Texas attack, Mr. Hassan linked to the planned cartoon event in Texas, praised the January shootings at a satirical newspaper in Paris and called on jihadists in the United States to follow that example.