An American man being held in Moscow on suspicion of spying was given a flash drive containing Russian “state secrets” before he was arrested, but did not know he had them and had not looked at them, his lawyer has said.

Paul Whelan, a former US Marine, was detained in Moscow at the end of December.

The arrest raised speculation that he could be swapped for one of the Russians held in the US, such as gun rights activist Maria Butina, who has pleaded guilty to acting as a foreign agent in the US.

Whelan made his first public appearance in court on Tuesday to hear the appeal of his arrest.

Russia US Spying
Paul Whelan (Pavel Golovkin/AP)

The judge upheld the previous ruling that ordered him to be kept behind bars at least until the end of February.

Whelan, who is also a citizen of the UK, Ireland and Canada, was kept in a glass cage and did not speak to reporters.

Spying charges carry a prison sentence of up to 20 years in Russia.

Whelan’s lawyer, Vladimir Zherebenkov, told Russian news agencies that when his client was detained at a Moscow hotel at the end of December he had something with him that contained “state secrets.”

The lawyer said that Whelan was a frequent visitor to Russia and that he asked an unnamed person to email him something about travel around the country.

Russia US Spying
Paul Whelan in a Moscow court (Pavel Golovkin/AP)

Whelan reportedly was not able to download it and then asked that person to put it on a flash-drive.

“He was expecting to see on the flash drive some personal information like pictures or videos, something like that, about that person’s previous trips around Russia,” Mr Zherebenkov told reporters.

“We don’t know how the materials that contain state secrets ended up there.”

The lawyer said the American was detained before he could open the files.

Mr Zherebenkov also said it was not clear what has happened to the person who reportedly gave the flash drive to Whelan.

Mr Zherebenkov said that the investigators have not yet disclosed which country he is accused of spying for.

Whelan, 48, was discharged from the Marines for bad conduct.

He works as the global security director for a US automobile parts manufacturer and lives in Michigan.

His family has said he was in Moscow to attend a wedding.