DIYARBAKIR, Turkey, March 30 (Reuters) – Turkish Prime Minister Tayyip Erdogan’s ruling AK Party failed to conquer the Kurdish bastion of Diyarbakir in Sunday’s local polls because they misjudged decades-old grievances by minority Kurds.

Jubilant Kurds took to the streets of Diyarbakir, the biggest city of the Kurdish southeast, to celebrate the victory of the pro-Kurdish Democratic Society Party (DTP) over the AK Party, which campaigned on a message of improving services in the impoverished region rather than stressing Kurdish identity.

The southeast has been torn by separatist violence since the Kurdistan Workers Party (PKK) took up arms against the state 25 years ago. Some 40,000 people have been killed in the conflict and ending it is seen as key to boosting Turkey’s security.

Turkish President Abdullah Gul stressed the point in Baghdad last week, calling on Iraqi Kurdish officials to do more to prevent the PKK from using Iraq as a base to attack Turkey. He also recognised the Kurdistan government in northern Iraq, a move expected to improve ties between the state and Kurds.

Erdogan’s Islamist-rooted party had hoped to dislodge the DTP from Diyarbakir and other local administration in the southeast after it swept the region in a 2007 general election.

But the DTP won 67 percent of the vote in Diyarbakir, pummelling the AK Party which took 31 percent of the vote.

The result was a big disappointment for Erdogan, who had worked hard to win the support of Turkey’s 12 million minority Kurds, telling them all Turkish citizens were equal and granting more rights to Kurds under pressure from the European Union.

Launching a Kurdish-language state television channel and handing free washing machines to locals did not convince them that the AK Party was best placed to run their cities. However the government is expected to continue pushing for reform.

DTP officials had accused the government of granting some rights to Kurds only to win votes and had pointed out the many restrictions that still exist on the Kurdish language.

"We are so happy that the DTP won. It is our party and this is our victory," said 21-year old student Pelin Altun.

"Only old, religious people voted for the AK Party. The young voted for the DTP because we are most concerned about our identity and the future and not about religion," he said.

"We are not barbarians here we just want our identity," said Yilmaz 34, a caretaker.

Dogu Ergil, an Ankara-based expert on Kurds, said the results had sent the message to Erdogan that "the road to Europe passes through Diyarbakir". The EU has long pressed Ankara to expand more cultural and political rights to Kurds.

"Kurds don’t want to be given rights by the government. They say it is their own rights and they want to exercise them because they belong to them," Ergil said.

The Turkish state has long feared that easing restrictions for minorities will lead to the carving up of the country founded on the ashes of the Ottoman Empire. In recent months the military has made conciliatory gestures, saying force might alone will not defeat the separatists.

DTP leader Ahmet Turk, whose party faces closure by the Constitutional Court on charges it has links to Kurdish separatist rebels, said the results were a success for Kurds.

"The people gave a lesson to the government. We got our votes back. Governments are temporary, people are always there."

(Editing by Daren Butler and Dominic Evans)