Former U.S. Marine Paul Whelan speaks from inside a defendants' cage during a court hearing in Moscow, Russia, June 20, 2019. REUTERS

Moscow — A Russian court has upheld an earlier ruling allowing the extended detention of a former U.S. Marine jailed in Moscow on espionage charges. Moscow's appellate court rejected Paul Whelan's appeal Tuesday against the ruling last year that granted Russian authorities permission to keep him in custody until March 29, pending a trial.

Whelan, 49, was arrested in a Moscow hotel room more than 13 months ago. Russian investigators claim he was caught red-handed after receiving a USB computer drive containing classified information. He denies the allegations and insists he was framed. Whelan's family says he came to Russia to attend a friend's wedding, and believed the USB drive handed to him by an acquaintance contained vacation photos.

The hearing on Tuesday was held behind closed doors and media were only allowed inside the courtroom to hear the verdict, without phones or cameras. Whelan was banned from speaking to the reporters.

Get Breaking News Delivered to Your Inbox

After reading the ruling, the presiding judge asked through a court translator if it was clear to Whelan.

"I knew the decision before I came here today," he replied from behind the glass of the enclosed defendant's cage. He was smiling and asked the judge if he could have a cake for his 50th birthday next month.

Days after he arrived in Russia, new U.S. Ambassador John Sullivan visited Whelan in jail last week in what became his first public appearance the country. The ambassador voiced concern over Whelan's health and called for his immediate release.

"It's time for this nightmare to end, and for Paul to go home," Sullivan said in comments published by the U.S. Embassy on social media.

Whelan's Russian lawyer Vladimir Zherebenkov said he and his team were almost done going over the case files with their client, all of which remain classified. The trial is expected to start this spring, he said.

Whelan, who also holds British, Irish and Canadian citizenship, faces up to 20 years in prison if convicted of espionage.