Turkey's ruling party has secured a stunning victory in a snap parliamentary election, sweeping back into single-party rule only five months after losing it.

Prime Minister Ahmet Davutoglu declared victory as results showed the ruling Justice and Development party won more than 49% of the vote and was projected to get 316 seats in parliament.

The preliminary result, after nearly 99% of votes were counted, would give the party a comfortable majority in the 550-seat parliament.

Following the vote, Mr Davutoglu struck a conciliatory tone, asking ruling party supporters to remain solemn and to embrace fellow Turks.

"Today is the day of victory but it is also a day for humility," he said, addressing supporters in his hometown of Konya.

The vote was a re-run of a June election in which AKP surprisingly lost its one-party rule due to a strong showing by a Kurdish party.

Most analysts had expected AKP to fall short again, but the preliminary results suggest it picked up millions of votes at the expense of the nationalist MHP and pro-Kurdish People's Democratic Party, or HDP. AKP's vote tally jumped nearly nine percentage points. The secularist CHP was hovering around the same result as in June.

With a dramatic gain that few had predicted, the ruling party's gamble to hold new elections paid off. Supporters at the party's Ankara and Istanbul headquarters waived flags in rapturous celebrations. Crowds outside President Recep Tayyip Erdogan's home in Istanbul shouted "Turkey is proud of you."

"It's a massive shift of vote compared to the previous election," said Fadi Hakura, a Turkey analyst at the London-based think tank, Chatham House. "Erdogan's focus on security and stability seems to have attracted Turkish and Kurdish votes."

While Mr Erdogan was not on the ballot, his long run of pre-eminence over Turkish politics looks set to continue. However, his party will fall short of a supermajority that he had sought to change Turkey's constitution and boost his presidential powers.

"We will all have to show respect to the national will," he said after voting in Istanbul. "Turkey has made great strides in democracy and this stride will be strengthened with today's election."

Amid renewed violence in Turkey following the June vote, Mr Erdogan and Mr Davutoglu argued that only a single-party majority could restore stability.

Fighting between Turkey's security forces and Kurdish rebels has left hundreds of people dead and shattered an already-fragile peace process. Two recent massive suicide bombings at pro-Kurdish gatherings that killed some 130 people, apparently carried out by an Islamic State group cell, also increased tensions.

HDP leaders attributed the fall in their votes to the violence and unfair election conditions.

HDP's co-chairman Selahattin Demirtas said the party was forced to cancel election rallies and television stations gave party representatives little air-time amid government attacks branding the party as the political wing of the Kurdistan Workers' Party, or PKK, which is considered a terrorist organisation by Turkey and its allies.

"I regret to say that there wasn't a fair or equal election... We were not able to lead an election campaign, we tried to protect our people against attacks," he said.

Preliminary results showed HDP hovering just above 10%, losing about three percentage points.

The HDP favours the resumption of peace efforts to end the Kurdish conflict.

Turnout in the election was about 87% among the 54 million people eligible to vote.

Turkish Deputy Prime Minister Numan Kurtulmus of the AKP said the results indicated that voters wanted stability. "The people wanted calm, they wanted security, they didn't want their peace disturbed," he said.

As vote tallies began to be reported, small clashes broke out in Diyarbakir in the Kurdish southeast between protesters and police.