Image caption The building problems involved wall and header ties which are used to hold exterior and interior walls together

More than 200 schools built in Scotland under private finance initiative (PFI) schemes are now at least partially owned by offshore investment funds.

Under PFI, the private sector builds and manages school buildings in return for a fee, typically over 25-30 years.

In one project in Edinburgh, 17 new schools were built, with the council paying £1.5m a month.

Analysis for the BBC found there had been 13 trades involving equity in the Edinburgh schools scheme since 2001.

BBC Scotland Investigates: How Safe is My School? is on BBC One Scotland at 19:00 on Monday 22 August.

Although published data does not confirm the exact number of PFI schools owned wholly or partly offshore, it is clear they represent the vast majority.

Stakes in PFI building projects can be sold. They can then be traded on the secondary market to become parts of larger investment funds and pensions, as the monthly fees paid by councils provide a steady income.

Media playback is unsupported on your device Media caption Edinburgh schools: 'Children shelter under that wall'

Dexter Whitfield, from the European Services Strategy Unit, told a BBC Scotland investigation the Edinburgh PPP1 scheme was now owned by four different companies.

"Those four different companies are located offshore in Guernsey and Jersey, and they are basically controlled by shareholders," he said.

A critic of PFI, he has described the projects as "wealth machines", adding: "There are an awful lot of people making very substantial sums of money out of it."

The 17 schools built in Edinburgh under PPP1 were closed for repairs earlier this year after construction faults were found.

The problems - with wall and header ties, used to hold exterior and interior walls together and attach them to the rest of the building - first became apparent when part of a wall at Oxgangs Primary fell during stormy weather.

About 7,600 primary and secondary school children in the capital were eventually affected.

An independent inquiry into the matter will consider whether the private finance method contributed to the structural issues with the buildings.

Scottish PFI schools Key figures 2,544 state schools in Scotland 350 PFI schools (estimated)

277 owned at least partly offshore

80% owned at least partly offshore PA

The City of Edinburgh Council said the schools would be safe and well-maintained for as long as the contract is in place.

Andrew Kerr, the chief executive of City of Edinburgh Council, said the terms of the contract ensured that schools are kept in a good condition.

"That's something that was decided 10, 15 years ago. Our job is to make sure we manage that contract going forward as well as it can be," he added.

There are 93 PFI projects in Scotland - responsible for hundreds of schools, road, hospitals and energy projects - and worth more than £6bn.