At first, President Xi looked as if he was going to simply ignore the impudent foreigner. He instructed the moderator to move on, taking a scripted question from a Chinese state-owned paper. Mr. Obama, who was clearly eager to hear Mr. Xi’s answer, shot me a glance and a theatrical shrug, the presidential equivalent of “nice try, buddy.”

It turned out that Mr. Xi was merely biding his time. After he answered the Chinese journalist, he circled back to me and delivered a curt lecture. No, he said, the pivot was not about containment. And the visa problems of The Times were of our own making.

China protected freedom of expression, he said, but “media outlets need to obey China’s laws and regulations. When a car breaks down on the road, perhaps we need to get off the car to see where the problem lies. And when a certain issue is raised as a problem, there must be a reason.”

“In Chinese, we have a saying,” he concluded. “The party which has created a problem should be the one to help resolve it.”

As the White House press corps filed out of the room, one of my colleagues joked that he hoped the Chinese would allow me to leave the country. The Chinese media reported that I had violated the ground rules by directing a question to Mr. Xi, rather than only to Mr. Obama. (The White House did not instruct me to address only the American president.)

The whole negotiation was somewhat opaque, Mr. Earnest recalled this week. Even as he stood next to the leaders in the Great Hall that day, he said he was not sure the Chinese would follow through on the agreement.

The episode apparently did not sit well with the Chinese. On Thursday, Mr. Trump’s press secretary, Sarah Huckabee Sanders, said, “It was at the Chinese insistence there were no questions.”