* Ruling party says protesters must leave
* Offers referendum on plans for Gezi Park
* Protesters party on Taksim Square late into night
* Unrest sparked by crackdown on peaceful demonstration
By Nick Tattersall and Jonathon Burch
ISTANBUL/ANKARA, June 13 (Reuters) - Hundreds of anti-government demonstrators chanted and sang in Istanbul's Taksim Square early on Thursday, defying an order to end almost two weeks of protests against Turkish Prime Minister Tayyip Erdogan.
The deputy chairman of Erdogan's ruling AK Party, Huseyin Celik, said late on Wednesday that the protesters should withdraw from Gezi Park, a leafy corner of the square where they have set up a ramshackle settlement of tents.
At the same time, he made a concession by offering a referendum on the redevelopment plans that sparked the unrest.
A heavy-handed police crackdown on Gezi Park nearly two weeks ago triggered an unprecedented wave of protest against the perceived authoritarianism of Erdogan and his Islamist-rooted AK Party, drawing in a broad alliance of secularists, nationalists, professionals, unionists and students.
Riot police looked on from the fringes as crowds mingled late into the night, some protesters chanting and dancing, others applauding a concert pianist who took up residence with a grand piano in the middle of the square.
It was a surreal contrast to the scene 24 hours earlier, when tear gas sent thousands scurrying into side streets before authorities bulldozed barricades and reopened the square to traffic for the first time since the troubles began.
"The government can't accept these protests going on forever," Celik told a news conference in the capital Ankara following a meeting between Erdogan and a group of public figures linked to the Gezi protesters.
"Those with bad intentions or who seek to provoke and remain in the park will (now) be facing the police," he said.
Police fired tear gas and water cannon day after day in cities including Ankara last week. Three people, one a policeman, died and about 5,000 thousand people were injured, according to the Turkish Medical Association.
The offer to hold a referendum on the park redevelopment is one of the only concessions the authorities have publicly floated after days of firm rhetoric from Erdogan refusing to back down. Celik gave few details of how a referendum would be carried out, saying it could either be held across Istanbul, or just in the district near Taksim.
Protesters also want the government to punish those responsible for the violent police crackdown.
"We think it is indispensable that Gezi Park should remain as a park, violence should stop and those who responsible for violence should be investigated," said Ipek Akpinar, an architect who was among the delegation that met with Erdogan.
Erdogan has accused foreign forces, international media and market speculators of stoking conflict and trying to undermine the economy of the only largely Muslim NATO state.
Two foreign correspondents from the Canadian Broadcasting Corp (CBC) were detained by police on Wednesday and Canadian Foreign Minister John Baird said on his Twitter account that he had called the Turkish ambassador to voice concern. CBC quoted the Turkish ambassador to Canada as saying the journalists were expected to be released shortly.
Turkey's broadcasting authority said it was fining four television channels over their coverage of the protests on the grounds of inciting violence, media reports said.
President Abdullah Gul, who has struck a more conciliatory tone than Erdogan, said it was the duty of government to engage with critics, but also appeared to close ranks with the prime minister, saying violent protests were a different matter.
"If people have objections ... then to engage in a dialogue with these people, to hear out what they say, is no doubt our duty," Gul said. "Those who employ violence are something different and we have to distinguish them ... This would not be allowed in New York, this would not be allowed in Berlin."
Erdogan's tough talk has endeared him to voters for the past decade, but his opponents say it has now poured fuel on the flames. On Tuesday he said would not kneel before the protesters and that "this Tayyip Erdogan won't change".
The United States, which has held up Erdogan's Turkey in the past as an example of Muslim democracy that could benefit other countries in the Middle East, expressed concern about events and urged dialogue between government and protesters.
The European Union also raised concern about the police clearance of Taksim. Top EU officials have called on Erdogan's government to investigate cases of excessive force.
Erdogan argues that the broader mass of people have been manipulated by extremists and terrorists and says his political authority derives from his popular mandate in three successive election victories.