President Obama shakes hands with China's President Xi Jinping. (Petar Kujundzic/Reuters)

BEIJING — After days of behind-the-scenes lobbying by U.S. officials, Chinese President Xi Jinping agreed, as a gesture of diplomacy, to take a question at a news conference with President Obama. His answers, after being put on the spot Wednesday, were anything but diplomatic.

The setting at the august Great Hall of the People seemed primed for Xi to join Obama in basking in the glow of several major deals between China and the United States over climate change, trade and tourism in two days of bilateral meetings here. But after being challenged by a New York Times reporter over the Communist Party’s denial of visas for foreign journalists, Xi lashed out, insisting that the foreign press should “obey China’s laws” and look at themselves “to see where the problem lies.”

In a forceful and unusually blunt performance, Xi also denounced the pro-democracy protests in Hong Kong as an “illegal movement” and suggested that the United States and other western nations butt out of China’s domestic affairs. Although Obama had emphasized that he raised concerns over human rights, Xi countered that “China has made enormous progress in human rights. That’s a fact recognized by all the people of the world.”

Xi’s discourse did not completely overshadow the hard-won accords reached between the negotiators from both nations, which U.S. officials suggested were evidence that the two world powers could coexist in mutually beneficial ways. But the Chinese leader laid bare the deeper, more intractable differences that remain as the countries compete for influence in Asia and beyond — an undercurrent on display throughout Obama’s visit to a regional economic forum here this week.

Xi has sketched out a new “Asia Pacific dream” with China at the center, doling out tens of billions of dollars in aid to regional countries in what amounts to a new “Silk Road” of prosperity. The pitch has been widely viewed as a direct challenge to the Obama administration’s “pivot to Asia,” a strategic rebalancing of military, economic and diplomatic resources.

It was the idea that China and the United States are on an inevitable collision course that the Obama administration was eager to dispel here this week. Rather, the president sought to project a counter-narrative that the two countries can manage their differences, while focusing on shared interests.

White House aides worked overtime to avoid the embarrassing missteps of Obama’s first trip to Beijing in 2009, when his efforts at accommodation with China were characterized as weakness in the Chinese and U.S. media. Former Chinese President Hu Jintao refused to allow questions from reporters during that encounter.

Xi had taken a question from an American reporter after he and Obama held their first bilateral meeting last year at Sunnylands resort in Southern California. But White House officials were not convinced he would agree to do so in his own country and remained uncertain until the final hours before the news conference on Wednesday morning.

When Xi finally did agree to allow one question apiece for a reporter from each country, White House aides knew exactly which outlet they would instruct the Obama to call on: the New York Times, whose Web site has been blocked in China and some of its reporters banned from the country due to a series of stories exposing high-level corruption among Communist Party leaders.

The Wall Street Journal and Bloomberg News also have been sanctioned, and last year, Vice President Biden raised the administration’s concerns over the sanctions in a meeting with Xi in Beijing.

Mark Landler, who had done a reporting tour for the Times in Hong Kong, is well-versed in Chinese affairs. He asked whether Obama, despite the notes of harmony in both leaders’ official statements, was concerned by rising anti-American rhetoric in China.

Then the Timesman asked Xi two questions — one about whether he felt threatened by the Obama administration’s Asia pivot and the other about whether, in light of a new U.S.-China agreement to relax short-term visa restrictions for students, tourists and businesses, he would consider doing the same for foreign journalists.

Obama tried to defuse the questions by joking that he is used to being criticized by the press whether he is in China or the United States. “That’s part of being a public official,” he quipped.

Obama then tried to pre-emptively answer the question posed to Xi, emphasizing that the United States was in no way trying to contain China’s rise. He said he told Xi that while the United States supports free expression, the administration had in no way spurred the pro-democracy protests in Hong Kong. In his remarks, Obama had also made the point that the United States does not support independence from Tibet.

“I have consistently found President Xi willing to engage our differences in a frank and candid manner,” Obama said. “And I have consistently found ways to narrow those differences.”

Attention then turned to Xi, who had been writing something on a piece of paper while Obama spoke. But instead of answering, Xi instructed an aide to call on a reporter from China Daily, a state-run newspaper, who asked a mundane question about how China viewed its role in the world. U.S. reporters looked at each other in surprise that Xi was apparently going to act as if he had not been asked a thing.

Xi read a long answer from a script, suggesting he knew in advance what the Chinese reporter would ask. (China Central Television did not broadcast the news conference, suggesting Xi was doing his own stage-managing.) Not until the end of his remarks did he come back around to Landler’s questions about press freedoms, suddenly speaking without notes.

In one extended metaphor, Xi declared that if a car breaks down on the road, the driver would do well to get out of the vehicle and look for the self-inflicted damage: “In China, we have a saying: The party which has created the problem should be the one to resolve it.”

And with that, an aide declared the news conference over. The official delegations proceeded into a formal ballroom for a state lunch in Obama’s honor, at which Xi offered a toast.

The White House press corps returned to the hotel filing center, where Landler was greeted by a round of applause.