FILE - This undated file photo provided by the Maricopa County Sheriff's Department shows Abdul Malik Abdul Kareem. Court records show an undercover FBI agent who was investigating terrorism was driving past two Arizona men in 2015 just before they opened fire outside a Prophet Muhammad cartoon contest in suburban Dallas. An attorney for Kareem, of Phoenix, convicted of helping plot the shooting says in court records that the agent's presence raises questions about whether authorities could have done more to thwart the attack. (Maricopa County Sheriff's Department via AP, File) FILE - This undated file photo provided by the Maricopa County Sheriff's Department shows Abdul Malik Abdul Kareem. Court records show an undercover FBI agent who was investigating terrorism was driving past two Arizona men in 2015 just before they opened fire outside a Prophet Muhammad cartoon contest in suburban Dallas. An attorney for Kareem, of Phoenix, convicted of helping plot the shooting says in court records that the agent's presence raises questions about whether authorities could have done more to thwart the attack. (Maricopa County Sheriff's Department via AP, File)

PHOENIX (AP) — An undercover FBI agent who was investigating terrorism was driving past two Arizona men just before they opened fire outside a Prophet Muhammad cartoon contest in suburban Dallas in 2015, court records show, raising questions about whether authorities could have done more to stop the attack.

The records emerged in the criminal case against Abdul Malik Abdul Kareem, a Phoenix man who was sentenced this week to 30 years in prison on criminal convictions that included providing support to the Islamic State group. The Associated Press assembled a timeline of the agent’s involvement through court records and interviews that show how the FBI was at the scene of an attack by Islamic State sympathizers.

Two of Kareem’s friends, Elton Simpson and Nadir Soofi, were armed with semi-automatic weapons, body armor and had a copy of the Islamic State flag when they arrived at the anti-Islam event in 2015. Investigators say Kareem had trained them on how to use the weapons and watched jihadist videos with them. He was one of the first people brought to trial in the U.S. on charges related to Islamic State.

ADVERTISEMENT

Kareem wasn’t at the event in Garland, Texas, but the FBI was. Court records also show that the unidentified FBI agent was in contact with one of the gunmen days before the attack. In one social media exchange, the officer told Simpson, in a bid to keep the conversation going, “Tear up Texas.” The two attackers were killed in a shootout with police assigned to patrol the event, and a security guard was wounded.

The fact that there was an FBI agent at the contest in Texas who was in contact with Simpson has drawn criticism from Kareem’s lawyer and the security guard’s lawyer. They say the government has not been forthcoming about the agent’s role in the plot and have questions why the agency didn’t break up the plot.

“We are convinced that there is much more to this story than the FBI has admitted ,” said Trenton Roberts, an attorney for security guard Bruce Joiner.

The FBI declined to comment on whether the agency believed beforehand that Simpson and Soofi would launch an attack and on Kareem’s claim that the agent’s presence wasn’t revealed to avoid embarrassment. The Garland Police Department also declined to comment.

Kareem’s attorney cited the agent’s presence outside the event in requesting a new trial. A judge who rejected the request noted that Simpson didn’t reveal to the agent that he wanted to go to Texas to launch an attack.

The agent had been sitting in a vehicle outside the Garland convention center just as events wrapped up at the cartoon contest.

A dark sedan in front of the agent made an abrupt stop. As the agent drove around the car, two men with an Islamic State flag, wearing body armor and carrying military-style rifles, got out and opened fire.

ADVERTISEMENT

The agent drove away and was later stopped by police. The two men were killed in a shootout with law enforcement assigned to guard the controversial event, and the security guard was shot in the leg.

The agent’s presence at the contest wasn’t publicly revealed until 15 months later and has raised questions about whether authorities could have done more to stop the attack.

There was no mention at Kareem’s trial last year that an undercover agent witnessed the shooting and had exchanged social media messages with one of the men days before the attack.

The agent’s presence at the event was first revealed in August in court records in a criminal case in Cleveland against Erick Jamal Hendricks, a North Carolina man accused of trying to recruit people to join Islamic State.

Hendricks says he had been paid by the FBI since 2009 to help identify potential terrorists. He has pleaded not guilty to charges of conspiring to provide material support to the Islamic State.

More details emerged in December in court records in Kareem’s case, revealing for the first time the officer’s proximity to the shooters.

Kareem’s attorney said in court records that Hendricks put the undercover agent into contact with Simpson about 10 days before the attack. In one encounter with the agent, Simpson, who had a prior terrorism-related conviction, referred to the upcoming contest in Texas.

On the day of the attack, the agent communicated with Hendricks while the agent was outside the convention center. Hendricks asked about the size of the crowd, whether snipers were present and other questions, according to records.

The agent, according to an FBI record filed in Kareem’s case, snapped two photos from the convention center parking lot moments before the shooting. One shows a police officer and another person standing in the distance near a tree. The second image was taken less than 30 seconds before the shooting.

An estimated 25 to 30 officers were at the contest in Garland. Snipers were posted in nearby buildings, and officers stood guard in parking lots and drove around the convention center on motorcycles looking for anything suspicious.

In the days after the shooting, FBI Director James Comey said federal investigators learned only hours before the contest that a man under investigation for extremist activities might show up at the contest and alerted local authorities. Comey also said investigators had no indication that the man planned to attack the event.

Daniel Maynard, an attorney for Kareem, said in court records that the government hasn’t explained the agent’s presence at the contest. Maynard said the agent did little to stop the attack, according to court records.

Much of the evidence about the agent supports his client’s view that “this was not an unbiased investigation by the FBI to determine the truth, but a rush to judgment to get a conviction and to cover up the FBI’s own ineptness and misdeeds,” Maynard wrote.

___

Follow Jacques Billeaud at twitter.com/jacquesbilleaud. His work can be found at https://www.apnews.com/search/jacques%20billeaud.