UK local councils, faced with government plans that could result in them having to sell off up to 97% of their properties, will look on in envy at their counterparts in Germany, where some local councils are using a special legal instrument to snatch apartments from investors and place them in public hands.

German law gives municipal governments a vorkaufsrecht, or first purchasing right, over apartment buildings that come on the market. Largely forgotten during the years of stable property prices, this tool is now being used in Berlin to give back to local communities properties about to be sold to speculators.

The German housing market has been rapidly heating up in recent years, especially in Berlin, where apartment purchasing prices have increased 97.7% and rental prices by 51.1% since 2007.

Berlin’s wohnungsnot, or housing crisis, started under the previous Social Democrat mayor Klaus Wowereit, who oversaw the sale of more than 110,000 city-owned apartments – almost a third of the social housing stock – to investors, including Goldman Sachs. City officials are now attempting to reverse the disastrous effects, which reduced their ability to influence rental prices.

Hans Panhoff is the elected Green party councillor overseeing the building department in Berlin’s Kreuzberg-Friedrichshain district. The area once famous for its squats and high immigrant population is now at the centre of city’s recent property boom. “We have investors from all over the world seeking to put their money into Berlin real estate for security, and they don’t care how high the price is,” says Panhoff.

The housing trap: how can Berlin avoid following in London's pricey footsteps? Read more

Panhoff’s office researched the municipal right of first purchase and realised it enables the council to match any offer made by a prospective buyer of a property. Not only can the council buy the property itself, it can also exercise its right on behalf of a third party, such as a public housing company or a cooperative.

The opportunity to try this out arose recently when residents of a building in the popular Wrangelstraße approached the council for support after learning their property was to be sold to an investment fund for €3.7m (£2.9m).

The building is owned by Luxembourg-based asset management company Riva, whose business model, as set out in its publicity material, is to purchase apartment buildings in Berlin and sell them on at a higher price. The company says it generates value for investors by “acquiring buildings at wholesale prices (below replacement value) and selling apartments at retail prices”.

The right of first purchase gave the council, which did not itself have the funds to buy the property, just two months to finalise a deal. Panhoff’s office negotiated with Gewobag, one of Berlin’s city-owned housing companies, to take over the property, which would mean the residents would be able to stay in their flats, paying social housing rental rates.

It’s not all been plain sailing. Berlin’s skyrocketing property prices almost derailed the deal. Since the council can only match the bid of a private buyer, exercising its purchasing right means having to accept inflated prices. In this case, a not-for-profit foundation was found to fill the funding gap, but that might not be possible in other cases. One option could be to raise money through crowdfunding drives.

There are further restrictions preventing the widespread use of the communal right of first purchase. It can be used only in places that have been declared by the council as an area of special protection. There are 22 such neighbourhoods in Berlin, but they cover a small proportion of the city.

Facebook Twitter Pinterest Kristina Dietz hopes to see more community housing in Berlin. Photograph: Joel Dullroy

In a further complication, the Luxembourg-based investors have launched a legal challenge to the forced purchase. The case may take years to resolve, but until then the property remains off the market and residents are pleased about having benefited from the city’s interventionist policy.

Long-term resident of Wrangelstraße 66, Kristina Dietz, hopes this will be the start of a broader strategy to create more community housing in Berlin and greater support for self-determined or cooperative housing projects where tenants are included in decision-making. “We need to pressure the political decision-makers to use this instrument more often and successfully,” she says.

Joel Dullroy is a journalist based in Berlin

Join the Guardian Housing Network to read more pieces like this. Follow us on Twitter (@GuardianHousing) and like us on Facebook to keep up with the latest social housing news and views.