A £31m flood protection scheme for a town in the Scottish Borders has been officially opened.
The work in Selkirk to protect nearly 600 properties has seen burns rerouted and an "intelligent water management system" created at St Mary's Loch.
The Scottish government provided 80% of the funding for the project.
Environment Secretary Roseanna Cunningham opened the scheme along with Scottish Borders Council leader David Parker.
"Flooding can have devastating consequences for individuals, businesses and communities and that is why we are working with partners and investing in schemes to protect against flooding," said Ms Cunningham.
"The opening of this new scheme is good news for Selkirk and will provide lasting protection for around 600 properties against the sort of flooding that has affected this area.
"We are committed to reducing flood risk across Scotland. We will continue to make available £42m a year to fund important new projects to protect communities most at risk from flooding."
Mr Parker said the project had already proved its worth.
"This Saturday, the Long Philip Burn would have flooded the rugby club had it not been for the Selkirk flood protection scheme," he said.
"So already it is demonstrating what it can do and the properties and businesses and homes that it will protect."
He said the town had gone through a lot of disruption during the construction phase of the project.
"The community of Selkirk have been first-class, they really do deserve a great deal of praise for the way they have worked alongside the contractors and allowed us to deliver the flood protection scheme," he said.
"What we have delivered is a massive asset to the town and surrounding community with many new facilities being provided as well as making sure we are protecting the town from flooding."