(Adds background on current account, trade flows)
BRASILIA, Nov 26 (Reuters) - Brazil posted a wider-than-expected current account deficit of $4.166 billion in October, compared with a shortfall of $3.076 billion in September, central bank data showed on Thursday.
In the 12 months through October, the deficit was equivalent to 4.02 percent of Brazil's gross domestic product, down from 4.18 percent of GDP the previous month. The country attracted $6.712 billion in foreign direct investment last month, the central bank said.
Brazil was expected to post an October current account deficit of $3.7 billion, according to the median forecast in a Reuters poll of 18 analysts.
Current account is a broad measure of a country's international transactions including trade, profit remittances, interest payments and services including tourism.
Latin America's largest economy, a commodities powerhouse, is expected to post a trade surplus this year after a deficit in 2014, its first in 14 years.
The recovering trade balance is due largely to a drop in imports caused by a sharp slowdown in economic activity and a weaker currency, which has made Brazilian exports more competitive abroad.
Brazil's currency, the real, has lost 29 percent against the U.S. dollar this year. (Reporting by Marcela Ayres; Writing by Alonso Soto; Editing by Brad Haynes and Jeffrey Benkoe)