South Africa’s trade balance swung to a deficit in August after three months of surpluses as shipments of precious metals and stones, which include gold and diamonds slumped.

The R8.6 billion deficit compares with a revised surplus of R5 billion in July, the Pretoria-based South African Revenue Service said in an e-mailed statement on Friday.

South Africa recorded its first quarterly trade surplus in a year in the three months through June as mining exports surged, helping to narrow the deficit on the current account, the broadest measure of goods and services, to 3.1% of gross domestic product from 5.3%. The smaller current-account gap would benefit the rand, which has gained 12% against the dollar this year after losing 25% of its value against the US currency in 2015.

“Even though this month’s number is not good, the trend in 2016 so far is definitely better than last year, which is supportive of the rand,” Christie Viljoen, an economist at KPMG LLP in Cape Town, said, “It helps keep the current-account deficit lower.”

The cumulative surplus for the first eight months of 2016 is R7.4 billion compared with a shortfall of R35.1 billion in the same period last year.

Exports decreased by 5.5% to R90.2 billion as the shipments of precious metals and stones fell by 30% and vehicles and transport equipment declined by 10%. Imports rose by 9.2% to R98.8 billion as the purchases of mineral products, which include oil, increased by 24%.

The rand strengthened 0.7% to 13.7920 per dollar as of 3:57 p.m. in Johannesburg. Yields on rand-denominated government bonds due December 2026 fell one basis point to 8.66%.

Monthly trade figures are often volatile, reflecting the timing of shipments of commodities such as oil and diamonds.