HANOI — The White House abruptly banned four U.S. journalists from covering President Trump’s dinner here Wednesday with North Korea’s Kim Jong Un after some of them shouted questions at the leaders during their earlier meetings.

Reporters from the Associated Press, Bloomberg News, the Los Angeles Times and Reuters were excluded from covering the dinner because of what White House press secretary Sarah Sanders said were “sensitivities over shouted questions in the previous sprays.” Among the questions asked of Trump was one about the congressional testimony of his former attorney Michael Cohen.

The White House’s move to restrict press access was an extraordinary act of retaliation by the U.S. government, which historically has upheld the rights of journalists while a president travels overseas. It was especially remarkable because it came during Trump’s meeting with the leader of a totalitarian state that does not have a free press.

Trump’s exchanges with Kim were being covered by the standard 13-member traveling White House press pool, but ahead of the dinner, Sanders sought to exclude all reporters from the pool and permit only the photographers and television crew.

After loud pushback, including from photojournalists who protested, Sanders allowed a single reporter in the pool for the dinner: Vivian Salama of the Wall Street Journal, who was serving as the print pooler and did not ask a question at the dinner. In addition, at least two members of the North Korean media contingent, a photographer and cameraman, were seen covering the dinner.

Reporters for the three wire services, as well as a second print pooler, were excluded. They included two journalists who had asked Trump questions in the ­earlier appearances: Jonathan Lemire of the AP and Jeff Mason of Reuters. Also excluded were Justin Sink of Bloomberg and Eli Stokols of the Los Angeles Times.

In a statement, Sanders said: “Due to the sensitive nature of the meetings we have limited the pool for the dinner to a smaller group, but ensured that representation of photographers, TV, radio and print Poolers are all in the room. We are continuing to negotiate aspects of this historic summit and will always work to make sure the U.S. media has as much access as possible.”

Sanders did not specify whether the White House was retaliating against journalists who asked questions at the request of Trump or of Kim or the North Korean delegation. Asked by The Washington Post to clarify, Sanders referred to her written statement.

Journalists in the pool asked Sanders repeatedly whether North Korea was responsible for the White House’s decision to curb access, but she declined to give a direct answer. “I wouldn’t say that,” she said, according to two people present for the discussions.

Olivier Knox, president of the White House Correspondents’ Association, said in a statement that the group “strenuously objects to the capricious decision to exclude some journalists from a press encounter with President Trump and Chairman Kim.”

“This summit provides an opportunity for the American presidency to display its strength by facing vigorous questioning from a free and independent news media, not telegraph weakness by retreating behind arbitrary last-minute restrictions on coverage,” Knox continued. “We call on the White House to not allow a diminution of the previously agreed-to press complement for the remainder of the summit.”

Lauren Easton, a spokeswoman for the AP, said in a statement: “The Associated Press decries such efforts by the White House to restrict access to the president. It is critically important that any president uphold American press freedom standards, not only at home but especially while abroad.”

Norman Pearlstine, executive editor of the Los Angeles Times, said in a statement: “Previous administrations have often intervened to protect press access when foreign leaders have tried to limit coverage of presidential meetings abroad. The fact that this White House has done the opposite and excluded members of the press provides another sad example of its failure to uphold the American public’s right to see and be informed about President Trump’s activities.”

The move came a day after the U.S. press corps was kicked out of its filing center in Hanoi at the request of the North Korean entourage. The White House booked conference facilities at the Melia hotel as a press workspace, paid for by news organizations, but the hotel in the heart of the city also happened to be where Kim and his delegation decided to stay. As Kim’s motorcade headed toward Hanoi on Tuesday, Vietnamese officials suddenly booted the U.S. media from the hotel and relocated their operations to a separate site sharing space with the international press corps.

During Trump’s first visit with Kim on Wednesday night, American reporters asked Trump four questions during two brief photo opportunities; they asked Kim none. Eight North Korean reporters were also present for the summit — the entirely male contingent wore pins celebrating Kim Jong Un and were dressed alike — but they asked no questions.

When Trump and Kim first shook hands, Mason asked whether Trump had walked back his vow to denuclearize the Korean Peninsula. “No,” the president replied.

Lemire asked whether he would declare an end to the Korean War, to which Trump replied, “We’ll see.”

A few minutes later, when Trump and Kim sat down for their one-on-one meeting, Lemire asked Trump whether he had a response to Cohen’s testimony. Trump shook his head and did not answer.

Trump has long complained about reporters asking him questions at photo opportunities, especially when he is in the presence of foreign leaders; aides have said he views it as disrespectful and lacking in decorum. Trump has called the mainstream media “the enemy of the people,” and the White House occasionally has punished reporters for their questioning, including CNN’s Jim Acosta and Kaitlan Collins.

This was not the first time Lemire and Mason had asked uncomfortable questions of Trump on foreign soil. Both posed sharp questions to the president at his 2018 Helsinki news conference alongside Russian President Vladi­mir Putin. Trump later complained to aides about their questions, although he has since granted interviews to both reporters.

At Wednesday’s dinner with Kim, Trump made small talk with the press pool. “Everybody having a great time?” he asked.

After his press secretary kicked the four reporters out of the pool, Trump joked to Kim that the “media make us look very good!” The president also pointed to photojournalist Doug Mills of the New York Times and told Kim he was “one of the great photographers of the world.”

Past administrations have struggled to balance access for U.S. reporters as presidents have met with authoritarian regimes, including China, that have sought to limit the number of reporters in the room. When President Barack Obama met with Chinese Vice Premier Wen Jiabao on the sidelines of a regional summit in Bali in 2011, the White House barred wire services and a newspaper reporter from the photo op, allowing in only news photographers. That drew protests on the spot from the press pool, including a Washington Post reporter.

In 2009, when Obama made his first visit to Beijing, he held a news conference with China’s then-president, Hu Jintao, at which reporters from both countries were not allowed to ask questions. During a trip by Vice President Joe Biden to Beijing in 2011, U.S. reporters were ushered out of a meeting by Chinese security officials as Biden was still making his opening remarks, leading to a scuffle.

David Nakamura contributed to this report.