(Adds data and context)
BRASILIA, July 29 (Reuters) - Brazil posted a hefty primary budget deficit in June, central bank data showed on Friday, the latest in a string of shortfalls that highlight the government's challenges to rebalance overdrawn public accounts.
The primary budget deficit of 10.061 billion reais ($3.09 billion) in June, however, was below market expectations for a gap of 16 billion reais. That was largely due to the early payment of 5.2 billion reais from the sale of several hydroelectric plants.
The primary balance, which includes budget results prior to interest debt payments, is a key indicator of a country's capacity to repay its debt.
Brazil, which is reeling from a crippling recession, has now recorded four monthly primary budget shortfalls in the first half of 2016. It had a primary deficit of 18.125 billion reais in May.
The overall deficit, which includes interest from debt, narrowed to 32.174 billion reais in June from 36.256 billion reais a year ago. In the 12 months through June, the overall deficit was equivalent to 9.96 percent of gross domestic product.
($1 = 3.2510 Brazilian reais) (Reporting by Marcela Ayres; Writing by Alonso Soto; Editing by W Simon and Paul Simao)