“He asked how I had become involved in the protest and I mentioned the Center for Jewish Nonviolence,” Mr. Beinart wrote in a column published in The Forward on Monday.

“He asked if the center had incited violence, and I replied that, as its name suggests, it practices nonviolence. My interrogator then replied that names could be misleading. The government of North Korea, he observed, calls itself a democracy but is not. I told him I didn’t think the Center for Jewish Nonviolence and the North Korean government have much in common.”

The questioning ended when Mr. Beinart was asked if he would attend another protest and replied in the negative.

The Shin Bet internal security agency, which carried out the interrogations, issued a rare apology for Mr. Beinart’s detention, calling it an “error of judgment” by a field officer. The agency said it would look into the case, adding that it works only in accordance with the law and for the security of the state.

The Association for Civil Rights in Israel, a human rights organization, had complained earlier about the questioning of other activists at the airport. In response to those complaints, the attorney general’s office said two weeks ago that the cases had been passed on to the Shin Bet for inquiry.

There has been an increase in deportations of foreign, pro-Palestinian activists since the parliament passed legislation in 2017 barring entry to people considered to have taken significant action to advocate for boycotting Israel. The law was part of a campaign to counter the movement of boycotts, divestments and sanctions, which Israelis overwhelmingly oppose, consider anti-Semitic and view as calling for the country’s destruction.

Israel’s Ministry of Strategic Affairs and Public Diplomacy, which is charged with combating boycotts and related actions, published a list of about 20 organizations in January that would be affected by the law. It includes several American groups such as Jewish Voice for Peace, the Quakers’ American Friends Service Committee, the feminist group Code Pink and the United States Campaign for Palestinian Rights.