Keeping whales and dolphins in captivity will no longer be allowed across Canada under legislation that passed Monday, drawing celebrations from activists and politicians who called it a significant development for animal rights.

The federal bill, which now only requires royal assent to become law, will phase out the practice of holding cetaceans -- such as whales, dolphins and porpoises -- in captivity, but grandfathers in those that are already being kept at two facilities in the country.

"Today's a really good day for animals in Canada," said Green Party Leader Elizabeth May, who sponsored the private member's bill that began its journey in the Senate in 2015 before moving on to the House of Commons.

"Many scientists testified to why it was critical that we stop keeping cetaceans in captivity. We understand why because they are obviously not akin to other animals, for instance, livestock. Cetaceans require the ocean, they require the space, they require acoustic communication over long distances."

Gord Johns, the NDP critic for fisheries and oceans said the bill's passage marked "a celebration for cetaeans, for animals rights, the planet and our oceans."

The legislation, which had its third and final reading Monday, received support from the Liberals, NDP and Bloc Quebecois, with some Conservatives opposed.

It bans the capture of wild cetaceans, but does allow for the rehabilitation and rescue of the aquatic mammals. The bill also changes the Criminal Code, creating new animal cruelty offences related to the captivity of cetaceans. Breeding is also banned.

Imports and exports of cetaceans will also be banned under the bill, with exceptions only for scientific research or "if it is in the best interest" of the animal, with discretion left up to the minister, thereby clamping down on the marine mammal trade.

"This is a watershed moment for whales and dolphins, and powerful recognition that our country no longer accepts imprisoning smart, sensitive animals in tiny tanks for entertainment," said Camille Labchuk, executive director of advocacy group Animal Justice.

Animal rights group PETA said it was "popping the champagne corks today as Canada makes history."

"We look forward to a day when confining sensitive, complex marine mammals to tiny tanks is outlawed in every country around the world," Tracy Reiman, the group's executive vice-president, said in a statement.

Marineland in Niagara Falls, Ont., and the Vancouver Aquarium in British Columbia are the only two facilities in Canada that currently keep captive cetaceans.

The Vancouver Aquarium announced last year that it would no longer house cetaceans and has one dolphin left at its facility. That came after Vancouver's board of parks and recreation passed a bylaw amendment in 2017 banning cetaceans being brought to or kept in city parks after two beluga whales held at the aquarium died.

Marineland, meanwhile, has told the government it has more than 50 belugas at its facility.

It recently received approval to export two belugas, both owned by the Vancouver Aquarium, to a park in Spain. It also applied to move five more belugas to facilities in the United States, but hasn't received those approvals yet, a Fisheries spokeswoman said late last week.

The facility told the government it had problems with the way the whale and dolphin captivity bill was written, noting that it would be in violation of the Criminal Code when the law comes into effect since some of its belugas are pregnant and set to give birth this summer.

On Monday, it said it will comply with "all animal welfare legislation in Canada."

"Marineland began an evolution in our operation some time ago, and as that evolution continues we are confident that our operations remain compliant with all aspects of (the bill)," it said in a statement.

The head of Humane Canada, an animal welfare group, said the legislation was needed.

"If the bill didn't do something to end captive breeding, we could have ended up with a beluga farm in Marineland," said Barbara Cartwright.

Phil Demers, a former whale trainer at Marineland who testified at hearings on the bill, said he was "elated" at it passing.

"Marineland could never be again, if it wanted to start today," said Demers, a longtime critic of Marieland who is engaged in a legal battle with the facility.

Marineland, for its part, has long said it treats its animals well.

"Marineland Canada continues to be a facility where children can learn about and be inspired by cetaceans without invading their natural habitats or disturbing cetacean populations that live in the ocean," it said Monday. "We're proud of our work, and our contribution to research, education, and conservation."