BEIJING—China’s economy shrank 6.8% in the first three months of 2020 compared with a year earlier, the first such contraction since Beijing began reporting quarterly gross domestic product in 1992.

The collapse foreshadows the pain expected in the U.S. and around the world as the coronavirus pandemic shuts borders, halts business activity and cripples global supply chains.

Following...