RIO DE JANEIRO, Brazil (AP) _ A robust farm sector helped boost Brazil's economy in the second quarter, indicating that a prolonged slump may be ending, the government said Tuesday.

Brazil's gross domestic product, the total value of its goods and services, shrank by a smaller-than-expected 0.76 percent in the second quarter compared to a year earlier, the Brazilian Institute of Geography and Statistics said.

Compared to the first quarter, the GDP actually grew 0.93 percent in real terms, while the first-half GDP shrank 0.42 percent compared to the same period last year.

The performance exceeded the expectations of many private economists, who projected a year-on-year decline of around 2.2 percent in the second quarter.

Agricultural output grew 1.6 percent compared to the second quarter of 1998, the institute said. The 1999 grains and oilseeds harvest is a record 82.6 million metric tons, nearly 10 percent higher than last year's.

The services sector, which accounts for around 60 percent of Brazil's economic output, grew a slight 0.04 percent. Industrial output, however, contracted 3.2 percent in the period.

The first half also featured unexpectedly low inflation of nearly 4 percent. The institute said a decline in demand that followed January's currency devaluation took the pressure off prices and inflation.

Early this year, the government predicted the economy would shrink by 3.5 to 4 percent this year. But the estimate was revised in May to around 1 percent, and economists say recovery should speed up.

``We can expect to see a faster recovery in the third and fourth quarters,'' said Rubens Sandenburg, chief economist at ABM Amro bank in Sao Paulo.