Justice Carol Ross gave the province six months to make the change, the Vancouver Sun reported. Between 1973 and 2008, inmates at the Alouette Correctional Center for Women who gave birth in prison were allowed to keep their babies.
Brent Merchant, then the assistant deputy minister of corrections, axed the program, saying the department should not be responsible for infant care.
Ross agreed with the plaintiffs, two female inmates, and their advocates that the program helped keep families together. She said it helped both mothers and children and also improved the atmosphere in prison.
Since 2008, newborns have been removed from their mothers immediately.
Kasari Govender, executive director of West Coast Women's Legal Education and Action Fund, said the change was especially hard on Inuit and Indian women.
"This decision is a victory for highly vulnerable women and their children, who will now have much better prospects for future well-being," she said.