South African gold producers have reached a settlement with lawyers representing thousands of miners who contracted fatal lung disease, in the country’s largest-ever class action suit.

Officials said the six mining companies involved agreed to the 5bn rand ($395m) settlement on Thursday, Reuters news agency reported.

The lawsuit was filed on behalf of miners who contracted the lung disease silicosis, which is caused by inhaling fine silica dust and has no known cure, and tuberculosis in South Africa’s mines.

“This is an historic settlement, resulting from years of extensive negotiations. The agreement provides meaningful compensation to all eligible workers,” the lawyers said in a statement.

South Africa is one of the world’s biggest producers of gold, but the country’s mining companies have been accused of exploiting workers and neglecting their health and safety.

Almost all claimants are black miners from South Africa and neighbouring countries such as Lesotho.

Local media reported the draft settlement provides for a medical examination and compensation to mineworkers who have worked in South Africa’s gold mines from March 1965 onwards.

Individual claimants can receive as much as 500,000 rand ($39,500) for the worst cases of silicosis, TimesLive reported. There is no limit to the number of people who can make a claim.

The settlement will have to be approved by a high court before it is implemented.

Miners trapped underground

Hours after the settlement was reached, mining operator Sibanye-Stillwater said 13 miners were trapped underground in a gold mine after a cave-in on Thursday.

Three miners had been located and were in contact with rescue workers in the Masakhane mine.

“All efforts are being made to locate the 10 employees who remain unaccounted for, and safely recover all the affected employees,” the company said in a statement.