MOSCOW — An American accused of spying in Russia will spend the rest of the year in a Moscow prison, a judge ruled on Thursday, in a brief court session where the defendant said he had been assaulted by guards and denied medical care.

“My human rights are being violated, my life threatened, medical issues are being denied and my property stolen,” the defendant, Paul N. Whelan, shouted to reporters as the judge read his decision. Ten months after Mr. Whelan’s arrest, the court extended his detention for two months.

Standing in a defendant’s cage in the courtroom, Mr. Whelan said that Russia believes that “it caught James Bond on a spy mission, in reality they’ve adopted Mr. Bean on holiday,” adding that “no evidence of espionage has been provided and does not exist.”

Mr. Whelan, a Marine veteran and citizen of the United States, Canada, Britain and Ireland, appealed to leaders of these states to take firm action to have him released. It was not clear if the message had been heard by diplomatic representatives from the embassies of the four countries, who were quickly pushed out of the courtroom by bailiffs.