In the years Nicholas Young went to work patrolling Washington's Metro system, a federal prosecutor said, an FBI agent was lying awake at night worrying about what he might do.

As the first police officer to face terrorism charges in the United States goes to trial in federal court this week, FBI special agents and undercover operatives explained to jurors how they began investigating Young in 2010 — and why he was not arrested until August 2016. It was then that Young bought Google Play gift cards that prosecutors say he thought would be used by Islamic State recruits to download encrypted messaging applications.

During the years-long investigation of the Alexandria, Va., native, several law enforcement officials testified, Young repeatedly made violent remarks that were concerning but did not prompt immediate action. Prosecutors said a sting operation involving the gift cards was necessary to get a dangerous radical not just off the streets, but also out of law enforcement.

An FBI agent will testify that "he didn't sleep at nights because [Young] had talked about torturing and killing an FBI agent," Assistant U.S. Attorney Gordon Kromberg told the judge Tuesday.

But Young's attorneys countered, saying his arrest was an overreach born of frustration that a six-year investigation had yielded nothing of value.

An image of Young seized during a search of his home last year and filed in Alexandria federal court. (N/A/U.S. Attorney's Office for the Eastern District of Virginia)

In private exchanges, defense attorney Linda Moreno said in her opening statement, agents wrote they "hit the case with a defibrillator," saying "let's hope he goes one step further" and breaks the law.

"The FBI induced Nicholas Young, a police officer who had served with distinction, to commit a crime where none existed," she said.

Young, 37, who worked for the Metro Transit Police, hopes to be the first person since the­ Sept. 11, 2001, attacks to win a terrorism trial by arguing that he was entrapped by law enforcement.

In his opening statement, Kromberg pushed back against that defense, telling jurors the government would show that Young had long-standing inclinations toward terrorism and believed in an alliance between white supremacists and Muslim extremists against Jewish people.

"Young's hatred of Jews was quite extraordinary," Kromberg said.

Young participated in reenactments as an SS officer — "one of the most vicious terrorist groups that ever existed," Kromberg said. He said jurors would see a picture of the SS tattoo on Young's arm, showing that the police officer didn't just dress up as a Nazi — "he saw himself as that." Kromberg also said Young had a framed photograph of Hitler at his house and used an Israeli flag as a doormat.

Moreno told jurors that Young is no neo-Nazi but a libertarian with an interest in politics who was committed to his job in law enforcement and his country. "A six-year investment . . . and what they have to show for it are gift cards," Moreno said. "That's why they're talking about Hitler."

An undercover officer first met Young in 2010 while tracking suspected extremists in Northern Virginia, under the guise of being a recent convert to Islam and a U.S. Marine from Boston.

They hit it off right away, said the officer, who testified behind a screen and used the pseudonym Khalil Sullivan.

"We had good conversations" about work, politics and dating, Sullivan said.

Young was also part of conversations about terrorism, Sullivan testified, and spoke of his "animosity" toward the FBI. He believed he was being watched, and he talked about how he could take on agents at his home or how someone could attack federal buildings.

"There were times we were joking, times we were not joking," Sullivan said. He said Young's descriptions of potential clashes with federal agents were "hypothetical."

While the level of detail Young gave in describing a potential attack on a federal building was "a little alarming," Sullivan said, "I didn't take it as a plan."

Sullivan ultimately cut ties with Young at his bosses' direction; he was told to focus on another investigation.

There was no apparent FBI intervention when Young in 2011 twice went to fight against Moammar Gaddafi in Libya, but when he came back he was questioned by agents at Dulles International Airport.

In the summer of 2014, an undercover informant targeted Young more directly after meeting him at the All Dulles Area Muslim Society Center in Chantilly, Va.

Identified in court only as Mohammed, or "Mo," the informant posed as a military reservist of Palestinian descent. He told Young that, like him, he had gone to George Mason University, had religious conflicts at work and had clashed with his father.

The FBI paid him $34,000 to befriend Young, Mo testified.

Over Sprites and Afghan food, Mo said, he and Young discussed religion and politics.

Mo acknowledged Young asked him why he wanted to join the Islamic State, saying: "It's kind of nice here in the U.S., isn't it? . . . No one restricts us from practicing our religion here." Young once said the militants "sound like a bunch of criminals who are hungry for power and money," Mo said.

But then Young gave Mo extensive advice for joining the Islamic State undetected, and he sent Mo a text message suggesting he thought his friend was on vacation, according to the recorded conversations introduced in court.

Mo actually traveled to Turkey because the FBI was worried that Young, as a police officer, "had access to government records and would be able to check" if the informant had not actually left the country, FBI Special Agent John Minchello testified.

Young was by his own admission "paranoid," as he repeatedly told Mo in conversations played in court.

"The people that do this," he said of informants, "are going to be nice guys; they're going to be great guys."