The Spanish government has begun the process of eliminating the so-called "golden visa" scheme.
Under the scheme, foreign investors are provided with fast-tracked residency.
At a Cabinet meeting on Tuesday, ministers agreed to end the awarding of the visa, which can be obtained in exchange for buying property worth €500,000 (£428,000) or more.
The visa scheme was created in 2013 by the conservative government of Mariano Rajoy.
It was seen as a way of attracting badly needed foreign investment in the wake of the eurozone crisis, which hit Spain's property sector particularly hard.
A total of 6,200 visas were issued until 2023 for investment in property, according to the organisation Transparency International, although other sources put the number higher.
Nearly half of beneficiaries of Spain's Golden Visa - a total of 2,712 - were Chinese, according to Transparency International.
Russians were the next most numerous recipients, with 1,159, followed by Iranians (203), and citizens of the US (179) and the UK (177).
The "golden visa" scheme also provided residency in exchange for investing €2m (£1.7m) or more in state bonds, or for investing in emerging Spanish companies.
However, only 6% of visas were awarded for reasons other than the purchase of property, the government said.
Prime Minister Pedro Sánchez said his government's intention to scrap the scheme was intended "to guarantee that housing is a right and not merely the subject of business speculation".
He said that the majority of visas awarded were linked to the purchase of properties in places such as Madrid, Barcelona, Valencia, Málaga, Alicante and the Balearic Islands - all areas where the housing market "is under enormous pressure and where it is almost impossible for people who live and work in those places and pay their taxes each day to find affordable housing".
Some areas of the country have been particularly affected by rising rents, such as Ibiza, in the Balearic Islands.
Last year, the government introduced a housing law which aimed to cap rental increases in areas where they have been spiralling.
Mr Sánchez's left-wing allies in his coalition government had been calling for an end to the visa system.
However, critics say that its elimination will not improve matters.
"The problem with housing in Spain, both in terms of sales and rental, is not caused by the Golden Visa, but rather by the increasing lack of supply [of housing] and the accelerating growth in demand," said Francisco Iñareta, of the Idealista property portal.
However, pressure has also come from outside Spain, with the European Commission calling on EU members to clamp down on such schemes, in great part because of security concerns, especially since Russia's invasion of Ukraine.
In 2022, the UK government ended a scheme allowing wealthy foreign nationals to settle in the country if they brought assets with them.
The following year, Ireland scrapped its Golden Visa, while Portugal revised its own version of it, no longer allowing residency in exchange for property purchases.