The final tally of the federal government's legal bill for its fight to prevent women from wearing a face veil at citizenship ceremonies is $421,840.

The figure is included in a document obtained in an access to information request filed by CBC News.

The former Conservative government lost in Federal Court and again at the Federal Court of Appeal before going all the way to the Supreme Court of Canada to try to reinstate its ban on women wearing a niqab while taking the citizenship oath.

The case had a huge impact on last month's federal election campaign.

It all started with a lawsuit from Zunera Ishaq, a devout Muslim woman from Mississauga, Ont. She moved to Canada from Pakistan in 2008 to join her husband. Ishaq agreed to remove her niqab for an official before writing and passing her citizenship test in 2013, but she objected to unveiling in public for the official oath-taking ceremony.

Earlier this year Federal Court Justice Keith Boswell said the government policy, introduced in 2011 on the direction of former citizenship minister Jason Kenney, was unlawful.

Citizenship judges must allow the greatest possible religious freedom while administering the oath. Boswell asked how that would be possible, "if the policy requires candidates to violate or renounce a basic tenet of their religion."

Jason Kenney introduced a ban on the wearing of religious face coverings such as the niqab at Canadian citizenship ceremonies late last year, sparking a legal battle with two women denied citizenship as a result. (Mark Taylor/Canadian Press)

The government then asked for another hearing at the Federal Court of Appeal. At the time Kenney said, "today's ruling not only goes against the democratic will of Canadians but against long-held Canadian values of openness and the equality of women and men."

The Federal Court of Appeal heard the case on Sept. 15, 2015. In a rare move, the panel of three judges immediately ruled from the bench and agreed that the niqab ban was unlawful.

The government appealed to the Supreme Court of Canada and the Conservatives turned their niqab ban into a wedge issue during the campaign that, in the end, did nothing to help the party.

The new Liberal Minister of Justice Jody Wilson-Raybould formally withdrew the leave to appeal two weeks ago, a move that put a stop to spending thousands more on what was seen to be a doomed legal campaign.