A Los Angeles undercover FBI agent posing as an Islamic State sympathizer testified Wednesday at a terrorism trial that a U.S. Air Force veteran revealed that he expected to be arrested when he returned to the United States from a trip to the Middle East.

The agent, identified only by the alias Talib Nassib, testified at the Brooklyn federal court trial of Tairod Pugh. It is one of the first of dozens of cases brought against suspected U.S.-based Islamic State sympathizers to reach trial.

Pugh, 48, has pleaded not guilty to charges that he went to Turkey last year, hoping to make his way to Syria to join the Islamic State.

The agent said he was wearing traditional Muslim religious clothing when he sat down next to Pugh at Kennedy Airport in an area where people waited to be cleared to enter the United States after a trip abroad.

He said the Neptune, New Jersey, resident told him he had been sent back to the U.S. from Egypt.

"On more than one occasion, he said he expected to be arrested," the agent said, recalling that Pugh seemed nervous whenever a law enforcement person passed by.

The agent testified that Pugh warmed up to him after seeing an Islamic State flag on his Facebook page. The agent said Pugh told him that if he went to Turkey, he should not look pious.

"He said: 'Shave the beard. Wear the pants.' He said the object is to blend in," the agent recalled.

At one point, the agent said, Pugh told him: "Allah willing, the next time I travel as a tourist to the area, I'll wear a Yankees baseball cap."

As the agent testified, a prosecutor played video and audio recordings of Pugh's airport encounter with the agent. Journalists were permitted to hear audio of the testimony but were kept out of the courtroom as the agent spoke, though Pugh's family members were permitted to watch in the courtroom.

The agent said Pugh told him he was stopped in Turkey and sent back to the U.S. because of his appearance.

"I don't want to get into the specifics ... with anybody or anything about my experiences," Pugh said, according to a transcript entered into evidence at the trial. "But I'll tell you how I got stopped. I was wearing a jellabiya. I looked like a Muslim."

On cross examination, defense lawyer Eric Creizman established that his client never told the agent he had any contact with the Islamic State or any plans to go to Syria.

Creizman also had the agent acknowledge that Pugh never said he wanted to wage jihad or become a martyr.