The ruling, and legal challenges to other opposition candidates, have thrown a shadow over this month's parliamentary election and a swearing-in ceremony that was due to take place in Ankara later on Tuesday.
The two members of the main opposition Republican People's Party
) – journalist Mustafa Balbay
and doctor Mehmet Haberal
– were detained on suspicion of belonging to a secret network planning to topple the government.
They stood in the June 12 poll, despite remaining in detention, and won their seats.
Lawyers for the two men launched an appeal for their release, which was turned down on Tuesday, broadcast media reported.
Kurdish candidates who won 36 seats in the vote were expected to boycott the oath-taking ceremony in a move that could force by-elections and stoke separatist violence.
The candidates who ran as independents from the pro-Kurdish Peace and Democracy Party (BDP) said they would shun the swearing-in after the Election Commission ruled that a colleague, Hatip Dicle, must forfeit his seat because of a past conviction for spreading "terrorist propaganda".
Separately a court ruled another five Kurdish candidates, detained on charges of having ties to the militant Kurdistan Workers Party (PKK), must remain in jail, stopping them from taking their place in parliament.
A candidate for the nationalist MHP party must also remain in jail, another court ruled.