Government crackdowns against protesters in Turkey could test the close ties between President Barack Obama and Turkish Prime Minister Recep Tayyip Erdoğan, a strategically important US ally in a tumultuous region.

The demonstrations in Turkey cropped up after Erdoğan 's visit to the White House last month, which highlighted a variety of issues on which the US needs its help. They include quelling the violence in Syria, stabilising Iraq and stemming Iran's nuclear ambitions.

Erdoğan, known for his brash and stubborn leadership style, has responded to the public outcry by questioning the legitimacy of the protesters. In a series of increasingly belligerent speeches to supporters, the PM warned that his patience was wearing thin and said those who do not respect the government will pay.

Hundreds of police in riot gear briefly fired tear gas canisters and rubber bullets at protestors in Istanbul's central Taksim Square early Tuesday, forcing many protestors, who had occupied the square, into a nearby park. Some groups also clashed with police at one edge of the square, setting off fireworks, firebombs and throwing stones at a police water cannon.

The clash mirrored previous confrontations between Turkish police and protestors, which have also involved the use of tear gas and water cannons. Turkish authorities are trying to halt the demonstrations, which have spread to nearly 80 cities across the country.

James Jeffrey, who served as Obama's Ambassador to Turkey until 2010, said that in private discussions among US officials "there's some wincing at the statements by Erdoğan." But in public, the White House has carefully avoided criticising the PM directly, though the US has urged Turkish authorities to exercise restraint. There also have been no known conversations between Obama and his Turkish counterpart since the protests began.

"We continue to have serious concerns about the reports of excessive use of force by police and large numbers of injuries and damage to property, and welcome calls for these events to be investigated," White House Press Secretary Jay Carney said. "We also continue to urge all parties to refrain from provoking violence." But he did not mention Erdoğan.

“This is always the quandary for the US government,” said Bulent Aliriza, a Turkey analyst at the Centre for Strategic and International Studies (CSIS). “When you get that close to an ally, you become very careful about criticising them.”

That is the pattern the US fell into with former Egyptian leader Hosni Mubarak, an autocrat who found favour with the US by protecting American interests in the Middle East. The US only turned on Mubarak after the Egyptian people launched mass protests against his government in 2011 as part of the Arab Spring push for democracy that swept through the region.

Despite the unrest in Turkey, Erdoğan does not appear in danger of losing power. But the protests have exposed pent-up hostility among many Turks, who fear Erdoğan is backsliding on his early record of democratic reform and seeking to impose his religious views on the secular nation.

The anti-government rallies started after the police launched a pre-dawn raid against a peaceful sit-in protesting against the plans to uproot trees in Istanbul's Taksim Square. Since then, tens of thousands of mostly secular Turks have joined the demonstrations, turning them into Turkey's biggest anti-government disturbances in years. For the White House, Erdoğan 's handling of the challenge to his leadership could complicate Turkey's close but complex relationship with the US.

Since taking office, Obama has taken significant steps to point to Turkey as a model for other majority-Islamic nations pursuing democracy and ties with the West. Three months after winning the White House, he put Turkey on the itinerary for his first foreign tour as President, a 2009 trip that was aimed in part at resetting the US relationship with the Muslim world. While touring Turkey alongside Erdoğan, Obama cast the ties between their two countries as a "model partnership." Since then, the two leaders have spoken frequently by phone, conferred on the sidelines of international summits and held two White House meetings, most recently in May.

Despite the robust relationship between the US and Turkey, Erdoğan has created headaches for Obama before. In 2010, Turkey broke with the US and voted against UN sanctions against Iran over its disputed nuclear programme. Erdoğan also ratcheted up tensions with Israel earlier this year when he called Zionism "a crime against humanity."

The lengthy civil war in Syria has exposed, perhaps, the deepest rift between Erdoğan and Obama. While both want Syrian President Bashar al-Assad out of power, the PM has become frustrated with Obama's reluctance to use military force to end the violence. Erdoğan pushed him during their recent talks to deepen US involvement in Syria, but the Turkish leader received none of the assurances he sought. Obama, however, has proven to have some measure of influence over his Turkish counterpart.

Earlier this year, Obama brokered a truce between Israel and Turkey, which had cut diplomatic ties following an Israeli attack on a Turkish aid flotilla bound for Gaza. Analysts say Erdoğan would have been far less willing to accept an apology from Israeli PM Benjamin Netanyahu had Obama not also been on the line during the phone call. Aliriza said Obama's success in restarting diplomatic relations between Turkey and Israel underscores the influence he could have now in shaping the PM's response to the protests. "There is only one man in this world that Erdoğan listens to, and that is Obama," he said.

The writer is a White House correspondent for AP.