BEIJING—China’s economy expanded at a faster-than-expected 6.8% in the first quarter, bucking expectations for a slowdown, though flagging exports and factory output may prove a drag in the coming months.

The pace of growth matched the previous quarter’s rate and confounded the predictions of some investors and analysts that the economy would slow early this year amid a government debt cleanup that has begun to crimp investment in property, infrastructure and factories. Retail sales held up particularly well, rising 9.8% in...