Environmentalists and animal rights activists have hailed the ruling as “historic”.

Regional president Maurizio Fugatti, of the right-wing League party, had ordered that the animal be killed following the attack, provoking widespread outrage in Italy.

The bear, a 14-year-old female known as JJ4, was identified thanks to DNA testing on the clothes of the two hikers who were attacked on Monte Peller, in the Non Valley.

It is not known yet if the bear, who’s been given the moniker Gaia, is accompanied by cubs, according to Italian news agency ANSA.

Animal rights groups appealed to the regional administrative court (TAR) against the order in a bid to squash what they claimed was an “injustice”.

Italy’s environment minister also wrote a letter saying he was against the culling of the bear.

“Only after collecting certain scientific information on the animal involved in the accident with the two citizens we will be able to evaluate technical solutions that, in my opinion, must not result in killing the animal,” Sergio Costa wrote to Fugatti.

Even the two hikers – 59-year-old Fabio Misseroni and his 28-year-old son Christian – appealed for authorities not to kill the bear.

On Friday, the court ruled that before provincial authorities resort to killing the bear, they must take other measures, such as capturing the animal and installing a tracking collar.

“JJ4-Gaia is safe, at least for the moment,” animal rights organisation LAV said on social media.

“But there will be other hearings.

“Together with our lawyers, we will do everything so that it can be safe forever.”

Experts estimate that there are between 82 and 93 bears in the province of Trento, not including cubs.