Turkey's Islamic-rooted ruling party won parliamentary elections by a wide margin Sunday, and the prime minister pledged to safeguard the country's secular traditions and do whatever the government deems necessary to fight separatist Kurdish rebels.

With more than 99 percent of votes counted, television news channels were projecting that Prime Minister Recep Tayyip Erdogan's Justice and Development Party would win 341 of the 550 seats, down from 351 in the outgoing parliament.

Erdogan, a devout Muslim, told supporters in his victory speech that he would preserve pluralistic democracy and work for national unity.

"We will never make concessions over the values of people, the basic principles of our republic. This is our promise. We will embrace Turkey as a whole without discriminating," he said at a rally in the capital Ankara.

Ruling party supporters clapped, danced and waved flags depicting the party symbol, a light bulb, outside the party's office in Istanbul. In Ankara, hundreds whooped as they watched election results on a big TV screen set up outside party headquarters.

"We are very happy," university student Reyhan Aksoy said. "God willing, great days await us."

The election was called early to defuse a showdown with the military-backed, secular establishment, which contended that Erdogan and his allies were plotting to scrap Turkey's secular traditions despite their openness to the West.

Erdogan raised concern with his efforts as prime minister to make adultery a crime and appoint former Islamists to key positions. Critics were also troubled by his calls for the lifting of restrictions on the wearing of Islamic headscarves.

Many government opponents constitute a traditional elite that has roots in state institutions such as the courts and the military — guardians of the secular legacy of national founder Mustafa Kemal Ataturk. But they have more of an authoritarian background and less of a reformist record than the government.

Although the ruling party's success has been touted as proof that Islam and democracy can coexist, the new government is likely to face persistent tension over the role of Islam in society.

"Democracy has passed a very important test," Erdogan said. "Whoever you have voted for ... We respect your choices. We regard your differences as part of our pluralist democracy. It is our responsibility to safeguard this richness."

The government will also have to decide how to deal with violence by Kurdish rebels seeking autonomy. NATO member Turkey is considering whether to stage an offensive into northern Iraq against separatist Kurdish rebels who rest, train and resupply at bases there.

Erdogan has warned the incursion could happen if security talks with Iraq and the U.S. fail. He has invited Iraqi Prime Minister Nouri al-Maliki to visit Turkey.

"In our struggle against separatist terrorists, we are determined to take every step at the right time," Erdogan said of the conflict with the Kurds.

The commander of Iraq-based Kurdish rebels told the Associated Press in an interview that he believes Turkey will quickly follow the elections with a long-anticipated offensive against his remote mountain bases.

Murat Karayilan, the leader of the separatist Kurdistan Workers' Party, or PKK, warned that his fighters were prepared for battle, but denied Ankara's charges that his group was using Iraqi soil to launch attacks against Turkish forces across the border. He was speaking on Friday.

Turkey has made big strides after the economic and political chaos of past decades, but some feared the vote could deepen divisions in the mostly Muslim nation of 70 million.

The country has an emboldened class of devout Muslims, led by a ruling party willing to pursue Western-style reforms to strengthen the economy and join the European Union. Under Erdogan inflation has dropped, foreign investment has increased, and the economy has grown at an annual average of 7 percent.

The success of the ruling party signaled continuity in economic reforms and in Turkey's troubled efforts to join the European Union.

"We will press ahead with reforms and the economic development that we have been following so far," Erdogan said in his victory speech.

One of Parliament's first jobs will be to elect a president. The post is largely ceremonial, but the incumbent has the power to veto legislative bills and government appointments.

In May, Foreign Minister Abdullah Gul abandoned his presidential bid after opponents said Gul's election would remove the last obstacle to an Islamic takeover of government and the military — instigator of past coups — threatened to intervene to safeguard secularism.

Though the ruling party emerged from the vote with a smaller majority than in 2002 elections, its officials expressed surprise with how well they did given the current atmosphere of tension with the secularists.

Two secular parties, the Republican People's Party and the Nationalist Action Party, won 112 seats and 70 seats, respectively, the television stations said.

Independents backed by a pro-Kurdish party seeking more rights for the ethnic minority won 24 of the remaining 27 seats, the stations said.

Many people cut short vacations to head home to cast their ballots, and lines at some polling stations were long. In Istanbul, Turkey's biggest city, police stood guard outside schools serving as polling stations.

Fourteen parties and 700 independent candidates competed for a total of 42.5 million eligible voters. Voting is compulsory in Turkey, though fines for failing to vote are rarely imposed, and 2002 election turnout was 79 percent.

Turnout was more than 80 percent, and voting was largely peaceful, election officials said.

Parties must win at least 10 percent of the votes in order to be represented in Parliament, a high threshold that has drawn some criticism as being undemocratic.

TV stations said that, with nearly all the votes counted, the ruling party had won 46.7 percent, even though it won a bigger percentage of seats at the expense of small parties that failed to clear the threshold.