* 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 after Prime Minister Tayyip Erdogan's AK party floated the offer of a referendum on development plans that stirred two weeks of protests.
The night passed peacefully, with young men playing soccer on the square at dawn, after several days of fierce clashes between police and protesters opposed to Erdogan. But it was not clear if the referendum offer would quell protests.
The pro-government Star newspaper declared in a front page headline: "The way out is a referendum".
"Referendum game", said Cumhuriyet newspaper, which is fiercely critical of Erdogan, whom it portrays as an increasingly authoritarian figure in Turkish politics.
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 for the square that first stirred the unrest.
A heavy-handed police crackdown on Gezi Park nearly two weeks ago triggered an unprecedented wave of protest against Erdogan and his AK Party - an association of centrists and conservative religious elements - drawing in 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 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 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.
"This seems to be a major about-face for the PM who, in early stages of the protests, said that the redevelopment plans would go ahead regardless and he would not 'ask a bunch of looters'," said Finansbank chief economist Inan Demir.
"We do not expect the protest movement to call an end to Gezi Park occupation on a vague signal of referendum...Yet, the more compromising attitude from the government might help ease acute domestic political pressure on lira-denominated assets."
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.