Yet Justice Thomas Au, who made the ruling, said that he would have made the same decision even without Beijing’s extraordinary intervention, and that the two had violated an existing Hong Kong law on oaths and declarations and a provision of the Basic Law, according to a 10-page summary of the decision handed out to reporters. The judge also ruled that the president of the Legislative Council could not let the two retake their oaths.

Mr. Au declared that their seats had been vacant since Oct. 12, the day they delivered their controversial oaths, the contents of which, including the coarse language, were included in the summary. Their names have now disappeared from a directory at the council’s office building. Lawyers for Ms. Yau and Mr. Leung had argued that a court ruling on their tenure as lawmakers violated the separation of powers and that their speech in the legislative chamber was protected and immune from legal action. The court rejected both arguments.

After the decision, Mr. Leung said he planned to appeal to a higher court in Hong Kong. Ms. Yau told reporters that the court’s decision was influenced by Beijing and that it undercut their democratic election. “If the court could strip us of our qualification, we all know what kind of society we live in now,” she said.

Now the focus turns to other elected members of the 70-member council who gave unorthodox readings of their oaths as a form of protest. Unlike Ms. Yau and Mr. Leung, the others either had their original oaths accepted or were given the chance to retake them, raising the legal bar on any attempt to have them removed.

Some pro-Beijing citizens in Hong Kong have asked the courts to use the new interpretation to have other lawmakers removed from office, including Nathan Law, one of the leaders of the 2014 protest movement, and Eddie Chu, who received more votes than any other candidate during the elections. Mr. Law gave a preamble to his oath, saying he could not be loyal to a government that “murders its own people.” Mr. Chu added a statement after he quickly read through his oath: “Democracy and self-determination. Autocracy will die.”

Also unclear is whether Ms. Yau and Mr. Leung will be able to run in a special election to fill their now-vacant seats. The wording of the Beijing interpretation specifies that candidates for office must also take a loyalty pledge, but determining whether that pledge is sincere gives election officials a great deal of discretionary power and is the subject of another legal case being argued in the city’s courts.