British Columbia's Court of Appeal has upheld a lower court ruling that struck down Canada's solitary confinement law.

The Appeal Court ruled unanimously that a law that allows for the prolonged and indefinite use of segregation in prison "offends the fundamental norms of a free and democratic society."

The federal government appealed the B.C. Supreme Court's ruling of the legal challenge brought by the B.C. Civil Liberties Association and the John Howard Society of Canada.

The Appeal Court allowed the appeal in part, saying that while the law should be struck down under section seven of the charter, it should not be struck down under section 15.

Grace Pastine, litigation director at the B.C. Civil Liberties Association, left, and Alison Latimer, pro bono lawyer of Arvay Finlay, following the ruling. (Maggie MacPherson/CBC)

Section seven relates to the right to life, liberty and security of the person, while section 15 protects equality rights, in this case of mentally ill and Indigenous inmates.

Parliament passed a new solitary-confinement law on Friday, but BCCLA executive director Josh Paterson says it still allows for inmates to be kept in cells the size of parking spaces for 22 hours or more a day.

The federal government did not immediately respond to a request for comment.