HONG KONG—China’s export boom took the country’s trade surplus to a record in 2021, as its manufacturing prowess and surging global demand beat headwinds including rising geopolitical tensions with the Western world.

Shipments from the world’s second-largest economy last year were up 30% from a year earlier to $3.36 trillion, also a record, the country’s General Administration of Customs said Friday. The booming export sector has been a consistent strength of China’s economy, which has been hit by domestic pandemic controls...

HONG KONG—China’s export boom took the country’s trade surplus to a record in 2021, as its manufacturing prowess and surging global demand beat headwinds including rising geopolitical tensions with the Western world.

Shipments from the world’s second-largest economy last year were up 30% from a year earlier to $3.36 trillion, also a record, the country’s General Administration of Customs said Friday. The booming export sector has been a consistent strength of China’s economy, which has been hit by domestic pandemic controls and a government-induced property-sector slump.

Imports were also up 30%, in large part a reflection of surging prices of commodities such as coal, steel and iron ore.

The result was a trade surplus of $676 billion in 2021, easily beating the previous record of $535 billion, set the year before, and highlighting how Covid-19 disruptions have only reinforced pre-pandemic global trade imbalances.

China’s trade surplus with the U.S. in particular grew to $396.5 billion, from $316.9 billion in 2020, Chinese customs reported Friday—a widening that could stoke more grumbling in Washington. China’s purchases of U.S. goods, including energy and agricultural products, fell well short of terms agreed to under the just-expired Phase One trade deal that the U.S. and China signed in January 2020, according to a study by the Washington-based Peterson Institute for International Economics.

China’s total goods trade—the sum of imports and exports—surged roughly 30% to a record high of $6.05 trillion last year, from $4.65 trillion the year before, China’s official data show.

The figures show that China has managed not only to maintain but to strengthen its central role in global goods trade, even as the U.S. and its allies warn Western companies about the potential perils of overreliance on China and alleged human-rights violations in supply chains running through the country.

Containers on the move in Qianwan Port in Shandong province this month.

Photo: Yu Fangping / Costfoto/Zuma Press

Beijing’s Covid-19 policy response, which since early in the pandemic has focused on eliminating the virus at home while giving priority to the resumption of factory operations, made the country a vital manufacturing base for the rest of the world, churning out essential goods including medical equipment and electronics for working from home.

And while many other countries’ factories continued to suffer Covid-related disruptions in 2021, China’s export machine kept humming through power shortages, global shipping snafus, soaring commodity prices—and curtailment measures imposed during periodic local outbreaks of Covid-19.

Logan Wright, director of China market research at Rhodium Group, argues that China’s zero-Covid policy intensified trends on both sides of the trade ledger, damp domestic demand for foreign goods while ramping up production of goods sold abroad.

Beijing’s policies “not only impacted China’s domestic consumption and appetite for imports, but at the same time, stimulus has been focused on resuming production while the rest of the world has been focused on maintaining household income,” Mr. Wright said.

Exports to the U.S., which China counts as its No. 3 trading partner—behind the Association of Southeast Asian Nations and the European Union—jumped 28% in 2021 from a year ago to $576 billion. shipments to the EU and the Southeast Asian bloc rose 33% and 26% respectively.

From mass tests to lockdowns, China is on high alert to keep the coronavirus at bay ahead of the Winter Olympics. WSJ examines the zero-Covid strategy in the city of Xi’an to see how it has sparked backlash from residents and affected chip makers. Photo: Shao Rui/Zuma Press, Fabrizio Bensch/Reuters The Wall Street Journal Interactive Edition

Electromechanical products, including mobile phones, computers and integrated circuits, made up nearly 60% of China’s exports last year. The strong export numbers were also bolstered by higher prices of goods.

The export sector served as a reliable pillar of growth throughout 2021 for China’s economy, otherwise beset by tighter regulations on technology giants, power shortages, soaring raw material costs and a crackdown on property developers’ debt levels.

Economists widely expect exports to play a smaller role in driving China’s overall growth this year, as the increase in global goods demand tapers off and other countries’ manufacturing capacity recovers.

“In 2022, China’s export development faces increasing uncertainty, instability and imbalance,” Li Kuiwen, a spokesman for China’s customs bureau, said Friday.

“We expect export momentum to ease in 2022 after exceptional growth in 2021,” said Tommy Wu of research firm Oxford Economics, as foreign consumers shift spending to services. New export orders for Chinese-made goods, such as work-from-home equipment and medical supplies, began to contract in August, according to China’s monthly surveys of purchasing managers in the manufacturing sector. This year’s export statistics will also suffer from hard comparisons with 2021’s robust numbers, he said.

The monthly data released Friday offered early signs that the nearly two-year-long export boom has begun to moderate a touch. December exports were up 21% from a year earlier, slowing from November’s 22% pace, while imports were up 20%, compared with 32% in November.

In addition, recent Covid-19 outbreaks, including one involving the more contagious Omicron variant, risks a fresh wave of port congestion, shipping delays and other supply-chain disruptions in the new year.

China’s trade surplus will likely contribute just 0.3 percentage point to gross domestic product growth of 5.3% this year, Standard Chartered forecasts. Last year, it estimates, the contribution was 1.5 percentage points to an overall growth rate of roughly 8%.

Likewise, economists predict China’s import-growth momentum to be muted this year, as the property-market downturn curbs the country’s appetite for industrial metals. Weak domestic consumption, meantime, will further damp overall demand.