(Recast, adds annual estimate)
By Alonso Soto
BRASILIA, Sept 26 (Reuters) - Brazil's current account deficit shrank in August to its smallest in almost a decade thanks to an improving trade balance, central bank data showed on Monday.
The country had a deficit of $579 million, below the $850 million shortfall forecast in a Reuters poll and the smallest since 2007.
A recession in its second year has dragged down imports while a weaker Brazilian real has helped bolster exports from one of the world's top producers of soy, sugar, corn and iron ore.
Still, the central bank slightly raised its 2016 external accounts deficit to $18 billion from $15 billion previously as recent gains in the real have reduced the positive momentum of the trade balance.
At the start of the year, the central bank estimated a external gap of $41 billion.
The country also attracted $7.2 billion in foreign direct investment in August, slightly above forecasts in a Reuters poll for an inflow of $7 billion.
Brazil posted a current account deficit of $4 billion in July, and a deficit of $4 billion in August of 2015. (Reporting by Alonso Soto; Editing by W Simon and Bill Trott)