US Secretary of State Hillary Rodham Clinton, gestures, as she takes an unannounced walk through Tahrir Square, Wednesday March 16, 2011, in Cairo. (AP Photo/Pau J Richards, Pool) (PAUL J. RICHARDS/AP)

Secretary of State Hillary Rodham Clinton delivered two strikingly different messages to the Middle East on Wednesday, praising Egyptians for their mostly peaceful transition from autocratic rule while scolding Bahrain for what she called an “alarming” crackdown on political dissent.

Clinton, in the Middle East for a three-day visit, issued an unusually sharp rebuke to Bahrain, where security forces used tear gas and rubber-coated bullets earlier in the day to clear hundreds of demonstrators from the Bahraini capital’s main square. Bahraini police were backed by personnel from four neighboring Persian Gulf states in clashes that reportedly left two demonstrators dead.

“They are on the wrong track,” Clinton told reporters in Cairo. “There is no security answer to this, and the sooner they get back to the negotiating table and start trying to answer the legitimate needs of the people, the sooner there can be a resolution.”

The violence in Bahrain and fighting in Libya overshadowed Clinton’s first visit to the region since Egyptian President Hosni Mubarak quit his post in the face of massive protests in Cairo’s Tahrir Square. Clinton paid tribute to Egypt’s pro-democracy revolution with a surprise visit to the famous plaza, where she shook hands with ordinary Egyptians. Some greeted her enthusiastically while others watched with indifference or bemusement.

“Welcome to Egypt,” some called out in English.

“Thank you for walking in Tahrir Square,” said one middle-aged man.

Afterward, Clinton called the experience “thrilling.”

“To see where this revolution happened and all that it has meant to the world is extraordinary for me,” Clinton said as she walked. “It’s just a great reminder of the power of the human spirit and universal desire for human rights and democracy.”

Clinton spent much of the day consulting with Egyptian leaders and others on an international response to worsening violence in Libya and Bahrain, while also hearing from a wide range of Egyptians on how the United States can support the country’s transitional government as it prepares for elections.

Clinton expressed dismay at the crackdown on protesters in Bahrain, saying the Obama administration has raised concerns with Bahrani leaders “at the highest level,” and also with four other gulf countries that agreed to send security forces to the Sunni-led country.

“We find what’s happening in Bahrain alarming,” Clinton said. “We think that there is no security answer to the aspirations and demands of the demonstrators.”

Clinton has been consulting with regional leaders on an international response to the fighting in Libya, as European allies push for new U.N. Security Council resolutions that could include authorization for a no-fly zone to shield Libyan rebels from assaults by Moammar Gaddafi’s warplanes.

“We are moving as rapidly as we can in New York to see whether we can get additional authorization for the international community to look at a broad range of actions — not just a no-fly zone, but other actions as well,” Clinton said. “We won’t know until there’s an actual vote. We’re hoping that will be no later than tomorrow. And then we’ll see what that message means to Gaddafi and his regime, and what it means in terms of support and encouragement to the opposition.”

The secretary called the Arab League’s decision to endorse a no-fly zone over Libya over the weekend “extraordinary.”

“I don’t want to prejudge the outcome” at the United Nations, Clinton said, “but I think many countries that had a negative view about taking any action began to reconsider that following the Arab League statement.”

Clinton arrived in Egypt on Tuesday with pledges of tens of millions of dollars in U.S. financial aid and business incentives to bolster the country’s transitional government and encourage deeper political and economic reforms.

The military-controlled interim government has continued to purge and arrest officials tied to abuses of the Mubarak era, seemingly to satisfy the protest movement’s demands. One of the most significant reforms came Tuesday when Interior Minister Mansour el-Eissawy ordered the dismantling of the state security agency, a sort of political police force that used fear and violence to protect Mubarak’s grip on power.

Often compared to East Germany’s Stasi, the Egyptian security apparatus deployed a vast network of informants and helped ensure loyalty to the regime by keeping dossiers, blacklisting dissidents, and controlling hiring in many institutions, including universities. Such interference was a major impetus for the student protest movement, and news of the dismantling was hailed on campuses Wednesday.

“The apparatus was running everything from appointing [department] heads, deans, teachers,” said Mohammed Abul-Ghar, a professor and longtime democratic activist at Cairo University. “All professors seeking positions at the university had to be approved first by state security. . . . High positions were based on approval of state security rather than academic qualifications.”

Protesters had demanded the abolition of the internal spy service, which had at least 100,000 employees, a state security official told Agence France-Presse. The Egyptian news agency said that part of the force will be rehabilitated and put to work in a new national security agency dedicated to “guarding the domestic front and battling terrorism.”

The Egyptian security services formed a close and controversial partnership with the CIA. A number of terrorism suspects captured by the U.S. agency were flown to Egypt for questioning, an extrajudicial process called extraordinary rendition. Human rights groups have asserted that some of those suspects were tortured.

The Obama administration has said it will retain rendition as a counterterrorism tool but will seek guarantees from any state it works with that suspects will be treated humanely.

Special correspondent Muhammad Monsour contributed to this report.