Beavers are to remain in Scotland and be listed as a protected species after a successful reintroduction.

The five-year Scottish Beaver Trial brought the creature back to the country after a 400-year absence with established populations in Argyll and Tayside.

The Scottish Government said beavers will be listed to prevent persecution but also "actively managed" to avoid any adverse impact on farmers and land owners.

The trial's results were sent to Scottish ministers in June 2015 but a decision on the reintroduction of the animal was delayed until now.

The animal was native to Scotland but was hunted to extinction in the 16th century.

A group of beavers were homed in Knapdale Forest, Argyll, as part of the trial, while another settlement emerged on the River Tay from illegal releases a decade ago.

Environment Secretary Roseanna Cunningham said: "I have been determined to find a pragmatic approach, which balances the biodiversity benefits of reintroducing beavers with the obvious need to limit difficulties for our farmers.

"Beavers promote biodiversity by creating new ponds and wetlands, which in turn provide valuable habitats for a wide range of other species.

"We want to realise these biodiversity benefits while limiting adverse impacts on farmers and other land users. This will require careful management.

"Today's announcement represents a major milestone in our work to protect and enhance Scotland's world renowned biodiversity.

"But I want to be absolutely clear that while the species will be permitted to extend its range naturally, further unauthorised releases of beavers will be a criminal act.

"Swift action will be taken in such circumstances to prevent a repeat of the experience on Tayside."

The Royal Zoological Society of Scotland (RZSS), which worked on the beaver trial, said the announcement is the first formal mammal reintroduction in UK history.

Chief executive Barbara Smith said: "Today is a truly historic day for Scottish conservation.

"Returning a keystone species to the wild for the first time in 400 years is a tremendous achievement for RZSS and our partners the Scottish Wildlife Trust, and we welcome the Government's commitment to the species both in Knapdale and further afield."

The Scottish Government will now carry out a Habitats Regulations Assessment and consider a Strategic Environmental Assessment.

Scottish Natural Heritage chairman Ian Ross said: "Our report to the Government, Beavers in Scotland, shows that beavers can have a very positive impact on the environment, wetland habitats and wildlife, as well as socio-economic benefits.

"We're now committed to working with land managers to minimise any potential negative effects the beavers might have on land use locally."

A spokeswoman for Rewilding Britain said: "We are delighted that beavers will be allowed to remain in the wild in Scotland.

"As recent trials have shown, beavers can deliver huge benefits for both people and wildlife through improved water quality, reduced flood risk and habitats for a wide range of species.

"We also welcome measures to manage the impact of beavers on farmers and other land owners.

"We urge the UK Government to put in place the same measures to protect and manage beaver populations in England and Wales."