Funding has been secured to restore a 200-year-old water system which powered a cotton mill complex in East Ayrshire.
The site at Catrine, which dates from 1787, consists of a weir, five reservoirs or "Voes", a sluice gate, a fish pass and a 450m-long tunnel.
Parts of the Scheduled Ancient Monument are in danger of collapse.
A £660,000 lottery grant has completed the £4m funding package which aims to restore the system and bring other parts of the site back into public use.
The Catrine water system was constructed by landowner Claud Alexander and textiles entrepreneur David Dale as part of a cotton mill complex.
It was powered by water wheels which harnessed the force of the River Ayr, from which water fell over a 15-metre drop.
When two 50ft (15m) breast-shot wheels were added in 1828, the site was, for a time, the most powerful water-powered system in the world.
The wheels, known locally as the Lions of Catrine, were dismantled in the 1940s as part of a post-war modernisation plan.
As part of the revamp, the water system will undergo conservation work.
A redundant chapel on the site will be transformed into a new community education and visitor centre.
An adjoining Victorian villa will house a new community enterprise centre.
A number of environmental improvements will also be made to the surrounding nature reserve.
A 1950s hydro scheme at the site will be restored using private finance with the resulting income used to maintain the water system and visitor centre.
Colin McLean, head of the Heritage Lottery Fund in Scotland, said: "For almost 200 years, the Catrine water system was central to the biodiversity and social history of the area as it brought with it jobs, housing and economic prosperity.
"This project demonstrates how history can be a living part of a modern community bringing people together to learn from, enjoy and benefit from their shared past.
"We recognise this community's passion and commitment to seeing their village regenerated through a celebration of its heritage and are delighted to give them our full support."
Stuart Nelson, chair of Catrine Community Trust, said: "The community trust and its supporters have worked tirelessly over the last five years in building the case for funding to save Catrine's amazing industrial heritage and provide much-needed facilities to convey this to the many people who pass though the village on the River Ayr Way.
"This generous award virtually completes the £4m funding package that once seemed very far away and provides a much-needed boost to the capacity of the trust to regenerate the village and provide employment."