JOHANNESBURG — Lawyers for gold miners in South Africa who got lung diseases while working underground over many decades have reached a compensation agreement in their class action lawsuit against mining companies.

The Legal Resources Centre, a South African group, said Thursday that the deal provides for "meaningful" compensation from the companies, which have estimated the total settlement cost at $395 million.

The companies are African Rainbow Minerals, Anglo American SA, AngloGold Ashanti, Gold Fields, Harmony, Sibanye Stillwater and Pan African Resources. Thousands could receive compensation.

Many people who are now sick worked in gold mines during white minority rule, when black miners received inadequate care and were vulnerable to silicosis and tuberculosis.

Safety remains a concern in mining, a pillar of the South African economy that has been in decline.