MOSCOW (Reuters) - Russia on Monday signed an agreement with a group of international scientists to free nearly 100 whales that have been held for months in cramped pens in Russia’s Far East, a scandal that has triggered a wave of criticism.

Images of the 10 orcas and 87 beluga whales, kept in enclosures in a bay near the Sea of Japan port of Nakhodka, first appeared after they were caught last summer by firms which planned to sell them to marine parks or aquariums in China.

Their plight angered animal rights groups and spurred a petition to release the whales, shared by actor Leonardo DiCaprio on social media, which gathered almost 1.5 million signatures online. Actress Pamela Anderson also posted an open letter to Russian President Putin on her website.

The Kremlin intervened and ordered local authorities to act, prompting Russia’s FSB security service to bring charges against four companies for breaking fishing laws.

But although the Kremlin agreed that the whales were held in cruel conditions, it said it was difficult to release them into the wild without harming them.

On Monday, however, international scientists, including Jean-Michel Cousteau, son of French marine expert Jacques Cousteau, signed a joint agreement with Russian scientists, backed by the local authorities, to free the mammals.

Their release is likely to be phased.

Slideshow ( 7 images )

“A decision in principle has been taken to release all the animals into the wild,” Oleg Kozhemyako, the governor of Primorsky Region, told reporters after the signing ceremony.

“Scientists from Cousteau’s team and Russian scientists will decide when and which animals to release.”

A special rehabilitation facility for whales would be set up under the agreement, with conditions as close as possible to their natural environment. Any whales in the Sea of Japan that were hurt or got into trouble could be treated there, said Kozhemyako.

Cousteau told reporters it was a very emotional moment for him and the scientists would do all they could to save the animals.

“I know it’s a lot of work, but I have no doubt that we are going to succeed,” said Cousteau.

The scientists promised they would devise a plan to release the whales, some of which were captured as long ago as July, by next month.

The Kremlin has said Russia has no direct ban on catching whales, but they can only legally be caught in specific circumstances, for scientific and educational purposes.