(Adds historical comparatives, data for first six months of year, debt to GDP ratio)
BRASILIA, July 31 (Reuters) - Brazil posted its second straight primary budget deficit in June, a weaker-than-expected result that raises fears that the government of President Dilma Rousseff could miss its key fiscal target for a third year.
Brazil had a primary deficit of 2.1 billion reais ($900 million) in June, the first gap for the month of June in at least a decade, according to central bank data released on Thursday. The country had posted a primary surplus of 5.429 billion reais in June of 2013.
The primary budget, which represents the public sector's excess revenue over expenditures before debt interest payments, had been expected to be a surplus of 200 million reais, according to the median forecast of 10 analysts surveyed by Reuters.
The country posted a primary deficit of 11.04 billion reais in May.
A 1.9 billion reais deficit recorded by the central government in June largely explains the negative result in the consolidated figure, which includes the federal, state and municipal governments.
In the first six months of 2014, the government has been able to meet 1.17 percent of its primary surplus target for the whole year. The government pledged to save at least 99 billion reais this year in primary surplus, or 1.9 percent of the country's GDP.
Brazil's public finances have deteriorated rapidly under Rousseff after she gave tax breaks to dozens of industries in an attempt to restart the country's stagnant economy.
Although the country's net debt is small compared to other major economies, it is no longer declining as it was over the past decade. The country's net debt as a percentage of GDP climbed to 34.9 percent in June from 34.6 percent in May.
$1 = 2.26 Brazilian reais Reporting by Alonso Soto and Luciana Otoni; Writing by Silvio Cascione; Editing by James Dalgleish and W Simon