Prime Minister Bulent Ecevit's Republican People's Party conceded defeat early today in midterm elections after early returns indicated it would lose all five contested National Assembly seats.

The concession could signal an end to the 21-month rule of Ecevit's moderate-leftist government, with oppostion forces led by the Centrist Justice Party of former prime minister Suleyman Demirel holding a slim majority.

Mustafa Ustundag, the ruling party's secretary general, issued a statement announcing the concession.

The loss of the five Assembly seats would give the opposition a majority of 227 in the 450-seat Assembly, in which Ecevit's party had held a two-seat majority before the crucial midterm balloting. The political violence that marred the campaign continued through the voting and six persons were killed.

Early returns with 5 percent of the vote counted in Istanbul, Turkey's largest city, showed Ecevit's party running neck-and-neck with the Justice Party, but the latter had a substantial lead foe the crucial Assembly seats in four western provinces.

Anticipating continued violence, the government had canceled all police and military leaves and stationed 200,000 troops at polling stations around the country.

In the eastern province of Mardin, four gunmen attacked a group waiting to vote, killing four persons and wounding two others, the police reported. They said soliders pursued the assasilants, killed one and wounded and captured the other three.

Authorities in Van, also in eastern Turkey, said a gunbattle between rival political groups at a polling station left one voter dead and another wounded.

At stake in the election were 50 of the Senate's 183 seats and more importantly, the five Assembly seats vacated by legislators' deaths since the 1977 general elections. The 450-seat Assembly is the more powerful house because it can topple governments through votes of no confidence.

Elections such as today do not ordinarily lead to a change of administration, but the numerical strength of the government and combined opposition parties was so close -- at 220 and 222 seats, respectively -- that the fate of Ecevit's Cabinet hung in the balance.

The election has the potential to heighten political uncertainity in this troubled NATO-member nation, whose strategic value to the West has been enhanced following the fall of the pro-Western Shah Mohammand Reza Pahlavi is neighboring Iran.

The election also comes at a time when Turkey is involved in negotiations about the future of U.S. military facilities on Turkish soil. Moreover, the country is facing a serious economic crisis.

Many political observers here fear that Turkey's military chiefs may decide to disband the parliament if the politicians fail to produce a government capable of resolving the country's mounting internal difficulties.