BEIRUT — Two officers from the Mukhabarat military intelligence came for the blogger Khodor Salameh one midnight in March, soon after he had written articles critical of the president and the army. He was to report for questioning in the morning — and it was not a request.

Such a scene is familiar in Syria — and much of the Middle East. But Mr. Salameh was in Lebanon, a country widely seen as the freest in the region.

Over the past year, the country’s reputation as a bastion of free speech has been tarnished by a rash of arrests, detentions and intimidation of Lebanese citizens for their online activities.

The level of Internet freedom “is better than in any other Arab country, but it is not good,” said Mr. Salameh. The 24-year-old blogger and journalist said he was held in detention for more than eight hours and threatened with prosecution unless he stuck to writing poetry rather than politics.

In June and July, four people were arrested for comments posted on the social-networking site Facebook about Michel Suleiman, the president of Lebanon.

In the 2010 press freedom index compiled by Reporters Without Borders — which takes restrictions on Internet freedom into account — Lebanon ranked above every country in the Arab world, in addition to Israel and Iran. Still, its ranking dropped 17 places from 2009.

Red lines have emerged: The most dangerous topics to speak out against online are the army and the president.

“The army is uncriticizable, especially after Nahr al-Bared,” said Farah Qobeissy, a socialist activist and blogger, referring to the Palestinian refugee camp where the Lebanese armed forces fought a pitched three-month battle with the Islamist extremist organization Fatah al-Islam in 2007. In that engagement, the army “were pictured as kind of a savior to Lebanon,” she noted.

Other taboos include in-depth discussions of the 1975-1990 civil war and subjects that could give religious offense.

Under Lebanon’s penal code, defamation is a criminal offense. This statute has given the authorities the power exercised by the four Facebook arrests and has left some Internet activists self-censoring their work.

Over the summer, too, some members of the government tried to push through a law governing electronic transactions. Critics, however, have pointed to vaguely worded clauses in the draft bill that could be abused. One clause would require licenses for a hazy range of “online services,” which some feared could cover blogs and news Web sites. Other sections gave the authorities access to private information and the right to go through the records of any company or organization dealing with the Internet.

“It reads like it’s a mechanism for warrantless search and seizure,” said Mohamad Najem, the president of Social Media Exchange, a local organization that trains civil society and non-government organizations to use social media technologies.

The group spearheaded efforts to postpone a vote on the proposed law in June. Using Twitter, blogs and Facebook, it spread the word about the dangers of the new law, while also lobbying legislators to explain its concerns. The effort eventually paid off, with a decision to delay the vote.

Elsewhere in the Middle East, violations of Internet freedom are rife. A number of states including Saudi Arabia, Egypt, Syria and Iran are listed as “Internet enemies” by Reporters Without Borders for their imprisonment of Web activists and restrictions placed on Internet access.

In Lebanon, things are not quite as bad, but Nadim Houry, the director of Human Rights Watch’s Beirut office, described the latest infringements on Internet freedom in Lebanon as “a step in the wrong direction.”

The committee that drew up the e-transactions law was headed by Lebanese Parliament members who belonged to Prime Minister Saad Hariri’s Future Movement. Some critics have suggested that the law was inspired by Internet laws in Saudi Arabia, a country that has close ties to Mr. Hariri.

“We can’t think that Lebanon thinks about these things in isolation — they don’t think about anything else in isolation,” Mr. Najem said.