A female orca leaps from the water in Puget Sound west of Seattle. (Elaine Thompson/AP)

Canada has banned the practice of keeping dolphins, whales and porpoises in captivity after a long-fought-for piece of legislation passed resoundingly Monday.

The Ending the Captivity of Whales and Dolphins Act, which Canadian media nicknamed the “Free Willy” bill, outlaws captivity, breeding, trade, possession and capture of cetaceans.

The measure, which was first introduced in 2015, passed by a wide margin in the House of Commons on Monday, had been championed by animal rights groups such as Humane Society International, Animal Justice and the Whale Sanctuary Project. It was passed previously by the country’s Senate.

“The passage of Bill S-203 is a watershed moment in the protection of marine animals and a victory for all Canadians,” Rebecca Aldworth, the executive director of Humane Society International/Canada, said in a statement. “Whales and dolphins don’t belong in tanks, and the inherent suffering these highly social and intelligent animals endure in intensive confinement can no longer be tolerated.”

Orcas, dolphins and other cetaceans have made for popular attractions at some aquatic theme parks for decades, but their presence has raised concerns about the ethics of confining whales for the purposes of human entertainment.

Lori Marino, the president of the Whale Sanctuary Project, noted in a statement about the bill’s passage that whales are “among the most cognitively complex of all animals.”

"Confining them to life in a concrete tank is truly unbearable for them,” she said.

These types of concerns swelled in the wake of the 2013 documentary “Blackfish,” which traced the life of a male orca named Tilikum from his capture at age 2, in the early 1980s, to the three human deaths to which he was connected. SeaWorld trainer Dawn Brancheau was killed by Tilikum in front of a live audience at SeaWorld in Orlando in 2010.

The documentary presented a largely empathetic portrait of these whales, examining the psychological harm they probably endure, having been captured in the wild, separated from their families and kept in close confines at various aquatic parks. It was watched by more than 60 million people.

SeaWorld, which was a focus of the documentary, was sharply critical of the production but eventually agreed to concessions as criticism of its treatment of whales persisted.

In 2016, the company, which had 29 orcas at its parks in San Diego, Orlando, San Antonio and in Spain’s Canary Islands at the time, agreed to stop breeding the animals and phase out their use at its parks.

Similar bills about keeping whales in captivity have circulated in the United States.

In 2015, the California Coastal Commission banned the breeding of orcas in captivity. And Rep. Adam B. Schiff (D-Calif.) has proposed a similar federal law about orcas.

In Canada, only two facilities keep cetaceans: Marineland, in Ontario, which has more than 50 beluga whales, according to CTV News, and the Vancouver Aquarium, which has one dolphin. Both will be allowed to keep the animals as long as they don’t breed more. CTV News reported that Marineland officials are wondering whether the current pregnancies of some of the belugas in their facility will cause problems after the mothers give birth this summer, given the bill’s passage.

Hal Whitehead, a biology professor at Dalhousie University in Nova Scotia and an expert on whales in the wild, testified in front of Canada’s lawmakers in support of the ban. He told The Washington Post that he did not believe that keeping whales in captivity was ethical.

“The environment in captivity is so utterly different from that in the wild in a number of ways which appear to be very meaningful to the animals,” Whitehead said.

He said orcas in the wild can swim 30 to 60 miles a day; their home range might be some 600 miles across. But this habitat is reduced to a concrete tank in captivity, shrinking a vast, three-dimensional range into a holding pen.

Orcas are social animals too, he said, forming societies along matrilineal lines. But those processes are completely disrupted in captivity, he said.

“The conditions are so different from what we’d consider to be normal conditions of life for these animals that I don’t think it’s ethical to keep them in captivity,” he said.

Read more:

The battle began when an Amazon Alexa was shot. It ended with a sheriff’s deputy saving a life.

She tried to steal a newborn by impersonating a social worker, police say. She wound up in jail.

A motorcyclist was struck by lightning while riding on I-95. Only his helmet survived.