The national strike which has paralysed much of South Africa's gold mining industry has been called off.
The workers want better conditions in hostels and higher pay
The National Union of Mineworkers (NUM) has asked its staff to resume work on Thursday evening, bringing the four day strike to an end.
South Africa's largest mining union earlier said that it had advised its members to accept a new pay offer.
Employers upped their offer to 6-7% on Wednesday, hoping to end the first industry-wide strike in 18 years.
More than 100,000 miners - about 70% of those working in the industry - had downed tools in protest at low pay and poor living conditions.
South Africa's Chamber of Mines, which represents the country's leading gold producers, confirmed that the strike had ended.
"The NUM has informed the chamber that it is calling off the strike and will start working by tonight," said Frans Barker, the chamber's head negotiator.
"Obviously we are very pleased we have reached a settlement."
NUM general secretary Gwede Mantashe told state television that the agreement was "a compromise mineworkers can live with".
The dispute was costing the industry - the world's largest bullion producer - an estimated 130m rand ($20m, £11m) a day in lost production.
Gold workers are generally paid about 2,500 rand ($388) a month.
Most still live in single-sex company barracks far from their families, a situation which has persisted since before apartheid laws were struck down in 1990-91.
Overcrowding has reduced in the hostels, the companies say, but many workers still live six or more to a room.
As well as keeping workers away from their families, the hostel system also acts as a breeding ground for tuberculosis and HIV, the NUM says.
Although the new offer fell well short of the 12% the NUM said it wanted, it was substantially better than the employers' initial offer.
"We have asked our delegates to recommend the offer to our members," said NUM general secretary Gwede Mantashe on TV news station CNN.
The strike has produced a rare example of white and black dominated unions working together during an industrial dispute.
About 10,000 members of Solidarity, a mainly white mining union, joined the NUM's action but subsequently recommended the new offer.
At the heart of the dispute has been the rise in both gold prices and the value of the rand.
Gold bullion is up almost a quarter over the past two years, partly because its traditional role as a secure investment in troubled times has re-emerged amid worries about economic growth and the cost of oil.
The rand, too, has appreciated - by more than 15% against the dollar over the same period.
Although this means lower returns for gold priced in US dollars, it also reduces the price of imported fuel and other overseas costs.