WASHINGTON – A Buffalo native who spent 20 years in the U.S. Navy found himself in federal court in Norfolk, Va., Thursday facing an indictment that accuses him of wanting to spill secrets to spies from Russia.

A federal grand jury indicted Robert Patrick Hoffman II, 39, on a charge of attempted espionage. Authorities said he tried to pass classified information to people who he thought were Russian agents – but who turned out to be FBI agents on a sting operation.

Hoffman, who retired from the Navy in November of 2011 as a petty officer first class with the rank of E-6, was trained as a “cryptologic technician-technical.” That means he gathered and analyzed electronic intelligence.

“While serving in the Navy, Hoffman held security clearances that granted him access to classified and national defense information relating to programs and operations in which he participated, and he repeatedly signed agreements to not disclose that sensitive information,” the U.S. Attorney’s Office for the Eastern District of Virginia said in announcing his arrest.

But on Oct. 21, authorities said, Hoffman tried to give some of that classified information to the Russian Federation.

The information Hoffman gave out “revealed and pertained to methods to track U.S. submarines, including the technology and procedures required,” prosecutors said in the indictment they filed Thursday.

Hoffman handed over documents “with intent and reason to believe that such information was to be used to the injury of the United States and to the advantage of a foreign nation, namely, the Russian Federation,” prosecutors added.

The information was classified as “secret,” meaning its unauthorized disclosure could result in “serious” damage to national security, the indictment said. That’s one grade below the “top secret” classification, which goes to information that, if released, could cause “exceptionally grave” damage to national security.

The indictment did not say how much money the undercover agents gave Hoffman in return for the information – but it said he must forfeit whatever he received as a result of his violation of federal law.

Hoffman, who now lives in Virginia Beach, Va., was arrested Thursday morning without incident, authorities said.

He made his first court appearance Thursday afternoon in Norfolk before U.S. Magistrate Judge Tommy Miller.

The Norfolk Virginian Pilot newspaper published pictures of Hoffman on its website that showed him smirking and grinning as he left the courthouse.

Hoffman, who remains in the custody of U.S. marshals, is due back in court for a detention hearing Tuesday. He faces a sentence of up to life in prison if convicted.

Few other details about Hoffman were available, although a search of his available addresses shows that he kept an address on Ridgewood Road in South Buffalo from February of 1996 through October of 2010, a period in which he was stationed in Pensacola, Fla.; Honolulu; and the Norfolk area.

Neither the indictment nor the Department of Justice news release on the case reveals any additional details about the sting operation that snagged Hoffman, or about why authorities suspected he might be interested in sharing government secrets with the Russians. However, the news release said: “The indictment does not allege that the Russian Federation committed any offense under U.S. laws in this case.”