In his ruling, Ontario Superior Court Justice Edward Morgan dismissed an application by three permanent residents, who argued the requirement was discriminatory and unjust.
"The oath of citizenship is a form of compelled speech," Morgan states.
"But it is saved by Section 1 (of the charter) as a reasonable limit on the right of expression that is justifiable in a free and democratic society."
Morgan also ruled the oath does not violate either religious or equality rights as the applicants claimed.
Selwyn Pieters, one of the lawyers involved, said they were considering an appeal.
"The finding that the oath violates freedom of expression is a positive step," Pieters said.
"But it is disappointing that the ruling found the violation to be demonstrably justified."
The Citizenship Act requires applicants for citizenship to swear or affirm they will be "faithful and bear true allegiance to Queen Elizabeth the Second, Queen of Canada, her heirs and successors."
The long-time permanent residents oppose the oath on religious or conscientious grounds, saying pledging allegiance to Canada should be enough to become citizens.
They also noted that people born in Canada or abroad to Canadian parents are automatically citizens and don't have to take any such oath.
The federal government maintained that taking an oath to the Queen has been around since Confederation as a condition of "acquiring membership in the Canadian polity."
"The inability to enjoy the benefits of citizenship — to hold a Canadian passport and to vote — are amongst the costs reasonably borne by individuals whose personal beliefs run counter to Canada's foundational heritage," the government argued.
It also insisted the three are in Canada voluntarily, and their political and religious views enjoy constitutional protections.
In siding with the government, Morgan noted that freedom of expression includes the right not to express views, but said the applicants' interpretation of the oath was somewhat extreme and showed a misunderstanding of its purpose.
They are, after all, free to oppose the monarch or advocate for its abolition, he said.
"The nation was born in debate rather than revolution," the judge said.
"Differences of opinion freely expressed are the hallmarks of the Canadian political identity."
One of the applicants, Michael McAteer, 79, a retired journalist who immigrated almost 50 years ago, has said his father was persecuted in Ireland for supporting Irish independence.
Swearing allegiance to the Queen would violate his conscience and betray his republican heritage, he told The Canadian Press.
Dror Bar-Natan, an Israeli, and Jamaican-born Simone Topey were the other applicants.
Reached in Geneva where he was travelling, Bar-Natan, a math professor, said Friday he had not had a chance to see the ruling and was unable to comment directly. However, he said the trio would likely discuss an appeal.
Topey says Rastafarians regard the Queen as the "head of Babylon" and an oath would violate her deeply-held beliefs.
Also on HuffPost