BEIJING — China suffered its worst economic contraction since at least the 1970s in the first quarter as it fought the coronavirus, and weak consumer spending and factory activity suggest it faces a longer, harder recovery than initially expected.

The world’s second-largest economy shrank 6.8 percent from a year ago in the three months ending in March after factories, shops and travel were closed to contain the infection, official data showed Friday.

That was stronger than some forecasts that called for a contraction of up to 16 percent but China’s worst performance since before market-style economic reforms started in 1979.

Some forecasters earlier said China, which led the way into a global shutdown to fight the virus, might rebound as early as this month. But they have