The Southeast Asian country's trade surplus came in at $3.435 billion in August, widening from a surplus of $43 million in July and beating a previous government forecast for a surplus of $1.7 billion, the Customs Department said in a statement.

Exports in August rose 12.6% from the previous month to $25.885 billion, while imports fell 2.1% to $22.450 billion, the department said.

Smartphones, garments and electronic home appliances were among the largest export earners in August. Main imports were electronics and machinery, the data showed.

Vietnam's exports of smartphones and spare parts, mostly produced by Samsung Electronics, rose 48% in August from July, the data showed. Samsung unveiled a new version of the Galaxy Note smartphones in early August.

Wednesday's data also showed Vietnam's trade surplus with the United States, Vietnam's largest export market, widened to $4.99 billion in August from $3.84 billion a year earlier.

Meanwhile, Vietnam's trade deficit with China rose to $2.48 billion in August from $1.37 billion a year earlier. Vietnam relies on China, its largest trading partner, for materials and equipment for its labour-intensive manufacturing.

For the first eight months of 2019, Vietnam's total exports climbed 8.1% from a year earlier to $171.296 billion, while imports were also up 8.1% at $166.071 billion, resulting in a trade surplus of $5.225 billion.

Its trade surplus with the United States in the January-August period widened to $29.82 billion from $22.14 billion a year earlier, while its deficit with China increased to $25.11 billion from $17.23 billion.

(Reporting by Khanh Vu and Phuong Nguyen; Editing by Andrew Heavens, Robert Birsel)

By Khanh Vu