By Yi Wei Wong

Indonesia's economy posted its first contraction in more two decades as the effects of the coronavirus pandemic cut into household income and business activity in the second quarter.

The country's gross domestic product shrank 5.32% from a year earlier, compared with a 2.97% expansion in the first quarter, the official Central Statistics Agency said Wednesday. The reading was worse than a median forecast for a 4.2% contraction in a Wall Street Journal poll of 10 economists.

"The global economy has been hit unusually hard by Covid-19, with effects being felt at all levels of society," said Suhariyanto, chairman of the statistics agency.

The contraction was Indonesia's deepest since the Asian financial crisis of the late 1990s. Indonesia recorded lower trade with most of its partners, although trade to China showed signs of recovery, the statistics agency said.

Measured on quarter, Southeast Asia's largest economy shrank 4.19% during the period, compared with a 2.41% contraction in the first quarter, as growth in key sectors such as transportation, food and beverage slowed, the statistics agency said.

Indonesian Finance Minister Sri Mulyani Indrawati last month estimated the economy would contract by about 3.8% in the second quarter and potentially enter a recession in the third quarter, as it wrestles with the lingering effects of movement restrictions aimed at curbing the spread of Covid-19. The country's coronavirus problem remains the worst in Southeast Asia, with 115,056 positive cases and 5,388 deaths from the pandemic, according to the latest statistics from the Health Ministry.

Ms. Mulyani has indicated she expects the economy to contract as much as 0.4% or grow up to 1.0% this year. Indonesia's economy grew 5.0% in 2019.

Write to Yi Wei Wong at yiwei.wong@wsj.com