Former Umbrella Movement protest leader Nathan Law was among those barred in a case brought by the semi-autonomous city's Beijing-friendly government after the four changed their oaths of office to reflect frustrations with Chinese authorities.
Beijing issued a special interpretation of Hong Kong's mini-constitution, the Basic Law, in November to insist that oaths be taken in a "sincere and solemn" manner.
The unprecedented intervention was prompted by a string of protests during the swearing in of lawmakers following citywide elections in October.
The High Court said Beijing's ruling was "binding" and that the court's decision to bar the four retrospectively was not politically motivated.
"The word 'solemn' bears the commonly understood meaning of being dignified and formal," the judgement said.
Concerns China is squeezing Hong Kong have sparked calls by some activists for self-determination or even independence for the city, angering Beijing.
The dismissed legislators were not staunchly pro- independence but at least two of them have advocated self- determination for Hong Kong.
They were attending a parliamentary finance committee meeting as the judgement was issued and were asked to leave. The session was abruptly adjourned.
The 24-year-old was one of the most popular candidates to win a seat, gaining 50,000 votes to make him Hong Kong's youngest ever lawmaker.
He called on protesters to gather Friday night.
"Suppression is not scary," he told reporters.
"The most scary thing is that people get used to it and are not willing to come out, to fight."
Veteran anti-China lawmaker Leung Kwok-hung, known as "Long Hair", who was also barred, appeared to choke up as he said: "It's ironic that it's Bastille Day today."
The judgement comes two weeks after Chinese President Xi Jinping warned any challenge to Beijing's control over Hong Kong crossed a "red line" when he visited the city to mark 20 years since it was handed back to China by Britain.
The handover agreement enshrined liberties unseen on the mainland, including freedom of speech and an independent judiciary, but Beijing has been accused of trampling the deal by interfering in a number of areas, from politics to education and media.
The cases against them and the other four lawmakers were initiated under the previous Hong Kong administration, led by unpopular former chief executive Leung Chun-ying.
He was succeeded by Carrie Lam on July 1, who is also seen as a puppet of Beijing by critics.
The oath of office requires lawmakers to repeatedly describe Hong Kong as a Special Administrative Region of China.
Law quoted Gandhi before taking his pledge, saying: "You will never imprison my mind", and used intonation to make his oath sound like a question.
Long Hair raised a yellow umbrella -- a symbol of the democracy movement -- during his pledge, which the court said did not reflect the "importance and seriousness" of the ceremony.
Former protest leader Lau Siu-lai failed to convey the oath's proper meaning by reading her pledge at a snail's pace, the court said.
Edward Yiu added lines to his oath, saying he would "fight for general universal suffrage", which rendered his pledge invalid according to the judgement.
(This story has not been edited by Business Standard staff and is auto-generated from a syndicated feed.)