Local communities have won a record-breaking £13 million deal from a French multinational company planning to build a wind farm near Edinburgh.

A healthy slice of the profits from 22 wind turbines proposed for Fauch Hill in West Lothian will be shared by surrounding towns and villages - plus all the profits from another turbine to be wholly owned by local people.

The deal, agreed after tough negotiations, is reckoned to be one of the best ever from a wind power developer, and could have major implications for other Scottish communities considering hosting wind farms.

The 69-megawatt wind farm is proposed by the Louis Dreyfus Group, a privately owned company founded in 1851 in Alsace, France. Two opinion polls have suggested it is backed by 60% of local residents.

But the development has been opposed by some environmental groups, and was rejected by West Lothian Council in 2012. Last year, it was the subject of a public inquiry, and is now awaiting a decision by Scottish ministers.

Community groups, meanwhile, have negotiated payments from Dreyfus of £5000 per megawatt per year, which is expected to total £8.25m over the 25-year lifetime of the project. The company is putting an additional £330,000 into a fund to improve energy efficiency and boost broadband locally in compensation for disruption during construction.

Unusually, Dreyfus has agreed to let the community own one of the three-megawatt turbines, and will lend the money to buy it on favourable terms. One conservative estimate says the turbine could net more than £4.5m over 25 years, though others suggest it could be two or three times that, depending on future electricity prices.

Dreyfus also promised the wind farm can be used by walkers, horse-riders and cyclists. It is planning a visitor centre, free parking and better access to the neighbouring Pentland Hills Regional Park.

Stewart McKenna, who chairs one of the local groups, Kirknewton Community Development Trust, predicted that the social and environmental benefits to local people would be "enormous". It was a hard-won victory that others could learn from, he said.

"Scotland's people and its renewable resources are two of our greatest assets," he said. "In combination they form a powerful positive force and will help to deliver a more resilient local democracy, better able to make decisions for itself."

The Kirknewton trust tried for seven years to develop its own renewable energy project, but had to abandon the idea due to lack of cash and land.

Instead, the community has driven a hard bargain with a foreign developer. "I cannot see how long-term, meaningful projects such as this can be delivered unless there is some form of partnership with a larger developer who is prepared to undertake the first and significant quantum of risk," McKenna argued.

The community benefits package agreed for the Fauch Hill wind farm was praised as "excellent" by Dr Richard Dixon, director of Friends of the Earth Scotland. "Locals have clearly bargained hard to get a good deal," he said.

"Simple financial contributions are welcome, but we would like to see the community owning a part of every new renewable energy development. The proposal at Fauch Hill sets an important standard for all the big renewables developers."

Deborah Chawner, director of Dreyfus's Fauch Hill Sustainable Energy company, said the project offered "the best package of community benefits". It included "valuable suggestions that were made to us by local groups".

She added: "If consented, this will represent a new model for community participation for communities hosting a wind farm in the future. In addition, all funds from both the cash element and the community turbine will be managed and distributed by local community development trusts."

Chawner was not aware of another community wind-power scheme in which the developer would finance a turbine with a low-interest loan for which the borrower was not personally liable. The Fauch Hill deal was a response to Scottish Government guidelines encouraging communities to take a share in wind-farm ownership, she said.

Scottish ministers have set a target for 500 megawatts of renewable energy to be owned by local communities by 2020. The aim is "to maximise the benefits for communities from renewable energy".