LONDON — A British judge upheld an arrest warrant for Julian Assange for the second time in a week on Tuesday, a significant setback for him after five and a half years of evading the authorities by living in the Ecuadorean Embassy in London.

Before a packed London courtroom, Senior District Judge Emma Arbuthnot rejected the arguments made by Mr. Assange’s lawyer, stating that he was not a prisoner, that his living conditions were nothing like those of a prison, and that he could have as many visitors as he liked. In fact, she said, he could — and should — walk free at any time to meet his legal fate.

“He is a man who wants to impose his terms on the course of justice,” Judge Arbuthnot said. “He wants justice only when it’s in his favor.”

If the judge had nullified the warrant, Mr. Assange, the founder of WikiLeaks, might have left the embassy, but that was far from certain. The United States and British governments have never publicly ruled out the existence of a secret request to extradite him to the United States, where he could face prosecution for publishing classified documents.