(Adds details on 2017 performance, outlook)
BRASILIA, Aug 1 (Reuters) - Brazil posted a trade surplus of $6.298 billion last month, government data showed on Tuesday, slightly below analyst forecasts but still the biggest for the month on record.
Exports totaled $18.769 billion and imports $12.471 billion. Economists in a Reuters poll predicted a surplus of $6.39 billion, according to their median forecast, following a surplus of $7.195 billion in June.
Brazil's growing trade surplus has helped to keep a steady flow of dollars coming into the recession-hit country, limiting currency losses amid an escalating political crisis.
Economists expect a record-high trade surplus of $60 billion this year, up from $47.7 billion in 2016, according to a survey released on Monday.
Brazil had a trade surplus of $42.514 billion between January and July, also a record for the period. (Reporting by Marcela Ayres; Writing by Silvio Cascione and Bruno Federowski; Editing by Chris Reese and Jonathan Oatis)