A modern-day Battle of Prestonpans is to take place not over fields but in a courtroom as a community makes a last-ditch attempt to buy land owned by a power giant for posterity.

East Lothian residents will launch one last charge to win the right of first option to buy the old Cockenzie Power Station land after its towers were razed last year, and the nearby site of the 1745 Jacobite battle, also owned by Scottish Power, as the company looks to sell.

The energy firm has the prime site on the open market and is in negotiations over a sale.

The infrastructure is in place, schools and amenities nearby and the site is just outside Edinburgh.

However a community group still hopes to stymie any potential sale in court to ultimately create a public haven.

Residents made a Community Right to Buy bid to the Scottish Government that would have given the group first option to buy.

The group is considering funding options to put together for their purchase once this was established.

But it was rejected by Scottish Ministers, and the residents are now appealing that decision at Edinburgh Sheriff Court next month.

An earlier move to create an energy park first prompted residents of Cockenzie, Prestonpans and Port Seton to set up their own pressure group called Coastal Regeneration Alliance.

After the energy park plan fell through the residents continued to push to keep the land available for local use.

Shona Brash, chair of CRA, said the community had enjoyed a balance between industry and local access to open spaces while the power station was operational.

She said: "We want to stress how important the balance is between industry and community.

"We want jobs but we also want space for public use.

"This (the court case) is our last chance."

The group behind the proposed community buy-out drew up a scheme that included arts impresario Richard Demarco's vision of creating an art gallery in the style of a Tate Modern for Scotland at the site.

Their plans included shops swimming pool, theatre and exhibition space.

There would also be a harbour and walkway between Cockenzie, Port Seton and Prestonpans, a playpark and mini-golf course on the Greenhills parkland and memorial garden at the site of the Battle of Prestonpans.

It was one of the first major battles in the second Jacobite Rising in 1745 and Scotland's victory over the English was a huge morale boost.

A spokesman for Scottish Power said: "We want the best for the site and are currently in negotiations."

The Scottish Ministers gave the reasons for the decision in a letter.

It read: "We accept CRA’S suggestion that, if delivered successfully, the proposals could bring future benefits for Prestonpans, Cockenzie and Port Seton and the wider community.

"However, while CRA provides evidence that its proposals will lead to some public benefit, and are generally in the public interest, it does not provide evidence that the application is one that shows that it is strongly indicative that it is in the public interest that the interest should be registered.

"There is no evidence supplied that any investigation work has been carried out to determine how and when such proposals will be implemented.

"It is also not clear who would take forward the various proposals."