(Adds comments from ministers throughout)
By Alonso Soto
BRASILIA, June 29 (Reuters) - Brazil posted on Wednesday its largest ever primary budget deficit for the month of May, highlighting the challenges the government faces to close a massive fiscal shortfall amid the worst recession for decades.
The primary deficit of 18.125 billion reais ($5.57 billion) in May topped market expectations for a gap of 17.3 billion reais.
It followed a surplus of 10.182 billion reais in April.
The primary balance, which excludes debt payments, is a key gauge of a country's capacity to repay its borrowing. The overall deficit, which includes interest costs, rose to 60.623 billion reais in May.
Acting Planning Minister Dyogo de Oliveira said on Wednesday that the government expects a smaller primary deficit somewhere above 100 billion reais in 2017.
The forecast will be revealed next week amid lingering doubts about the government's commitment to close a fiscal gap that cost the country its investment grade rating last year.
Michel Temer, who as vice president replaced President Dilma Rousseff during her impeachment trial in the Senate, is proposing capping public spending to limit this year's deficit, which is expected to swell to a record 163.9 billion.
May's large deficit was due mainly to a drop in the federal government's revenues as the economy faces what could be its worst recession in a century.
Despite the drop in revenues, the government announced on Wednesday an increase of 12.50 percent in the "Bolsa Família" program, a subsidy to the poor supported by Rousseff in recent years.
The increase will cost the government 2.1 billion reais per year, Social Development Minister Osmar Terra told reporters.
The ample deficits for this and next year would allow the Temer administration to spend more in order to gain political support for key pension and tax reforms, some critics say.
The two-year-long recession and past fiscal mismanagement have raised fears among investors that Brazil will be unable to service its debt in coming years.
The country's gross debt rose to an equivalent of 68.6 percent of gross domestic product in May from 67.5 percent the previous month. Brazil's debt, already high when compared to other emerging economies, is expected to reach 80 percent of GDP as early as 2017. ($1 = 3.2568 Brazilian reais) (Reporting by Marcela Ayres; Writing by Silvio Cascione and Alonso Soto; Editing by Daniel Flynn and Andrew Hay)