Beavers reintroduced to Scotland will be allowed to remain and will be given protected status, the Scottish government has announced.
Eurasian beavers taken from Norway were released at Knapdale in Argyll in 2009. An illegally-released population has also been discovered in Tayside.
Both groups will be allowed to expand naturally but will be managed to protect farmers and land owners.
Native Scottish beavers were hunted to extinction in the 16th century.
Environment Secretary Roseanna Cunningham explained the Scottish government's decision to grant beavers protected status.
"Beavers promote biodiversity by creating new ponds and wetlands, which in turn provide valuable habitats for a wide range of other species," she said.
"We want to realise these biodiversity benefits while limiting adverse impacts on farmers and other land users. This will require careful management."
Ms Cunningham said she wanted to "be absolutely clear" that while the beaver populations in Argyll and Tayside would be allowed to extend their range naturally, "further unauthorised releases of beavers" would be treated as "a criminal act".
"Swift action will be taken in such circumstances to prevent a repeat of the experience on Tayside," she said.
The two lead partners in the 2009 Scottish Beaver Trial - the Royal Zoological Society of Scotland and the Scottish Wildlife Trust - have both welcomed the Scottish government's decision.
Zoological Society chief executive, Barbara Smith, said it was "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... and we welcome the government's commitment to the species both in Knapdale and further afield," she said.
"Establishing a clear and comprehensive management plan for the species should now be our top priority."
Jonathan Hughes, chief executive of the Scottish Wildlife Trust, described the development as "a major milestone for Scotland's wildlife and the wider conservation movement".
He said: "Beavers are one of the world's best natural engineers. Their ability to create new wetlands and restore native woodland is remarkable and improves conditions for a wide range of species including dragonflies, otters and fish.
"The return of beavers also has great potential for education and wildlife tourism."
'Right of control'
Mid-Scotland and Fife MSP, Murdo Fraser, said the issue of beavers in Tayside had been "a long running issue...with strong opinions on both sides".
"For some time, I have been arguing for a compromise approach whereby the existing beaver population would be tolerated, but farmers and land managers would have the right to control numbers where agricultural interests were threatened.
"What we need to fully understand is what the government mean by 'active management' and what measures farmers and land managers will be able to take."
The Scottish Greens environment spokesman, Mark Ruskell, said he was "delighted" that beavers had been given legal protection.
He said: "Bringing this species back from extinction will make a huge contribution to restoring wetland habitat, boosting biodiversity while helping natural flood management.
"Farmers and land managers will need support from the Scottish government to understand how to work positively with wild beaver populations."