As the U.S. military on Thursday formally ended its intervention in Iraq and prepared to withdraw the last of its combat troops, China was watching warily and with deep concern about where those troops might go next.

The worry here is that an American military free of the nearly nine-year-long commitment to Iraq might now be freer to focus attention on the Asia-Pacific region, which China considers its back yard. In the past month, China has seen the Obama administration promise a pivot to Asia, with the establishment of a new U.S. military base in Darwin, on Australia’s northern coast, and Secretary of State Hillary Rodham Clinton’s visit to Burma, also known as Myanmar, which China considers an ally.

“In the past three or four weeks, the United States has launched so many initiatives so quickly,” said Shi Yinhong, a professor and director at the Center for American Studies at Renmin University in Beijing. “The motivation is to deal with China. This is a really significant new phase in America’s policy toward China.”

For the past decade, China has been free to focus on its economic development without concern about any major confrontation with the United States, as the foreign policy under the George W. Bush and Obama administrations focused almost exclusively on Iraq and the larger fight against terrorism.

Now, with the U.S. withdrawal from Iraq and the planned 2014 drawdown of troops from Afghanistan, Chinese officials are bracing to see whether President Obama’s announced refocusing on Asia presages an era of tense relations between China and the United States.

“America is now shifting its focus from the Middle East and South Asia to East Asia, from counterterrorism to dealing with emerging powers,” said Yuan Peng, director of the Institute of American Studies, part of the China Institutes of Contemporary International Relations, which is affiliated with the Foreign Ministry. “Maybe China will be the new focus. This is a very typical Chinese way of thinking.”

Yuan said the Iraq withdrawal “signals that counterterrorism as the only focus of your security strategy in the last 10 years has changed.” Now, he said, “the focus of strategic thinking, the center of gravity, is shifting from West to East.”

“It’s already become a reality that you’re here — you’re back,” he said. “The following question is: What’s that for? Is it for encircling or containing China?”

China also benefited materially from the war in Iraq. In 2008, two Chinese oil companies signed contracts worth $3 billion with the Iraqi government for oil exploration rights. PetroChina, China’s biggest oil company and an arm of the state-owned China National Petroleum Corp., is developing the Halfaya and Rumaila oil fields in southern Iraq.

The Iraq war helped deepen lingering anti-Americanism here among some Chinese, who view the United States as a “hegemonist” power bent on using its military for global domination. Experts said the sentiment was different during the U.S. invasion of Afghanistan, because that came after the Sept. 11, 2001, terrorist attacks by al-Qaeda plotters based in Afghanistan — and people in China believed the United States had a right to respond.

Some here said the 2003 Iraq invasion, based on the false premise that dictator Saddam Hussein possessed weapons of mass destruction, has made it more difficult for the United States to press its case against Iran developing a nuclear weapon.

But what was most unnerving may have been the prospect of seeing the United States send combat troops halfway around the world to overthrow a government and impose a fledgling democracy in the heart of the Middle East.

“Through the Iraq war, you’ve planted the seeds of democracy,” Yuan said. “Then you can see the Jasmine Revolution, the Arab Spring. . . . It changed the mind-set of the young generation.”

“In the long run, it’s in your interest because there’s a trend of democracy,” he said. “No one in China thinks it’s a big failure.”