* Nearly 300 accused of seeking to overthrow government
* Erdogan says he is fighting anti-democratic forces
* Critics say trial aimed at stifling opposition
By Ece Toksabay
ISTANBUL, Dec 13 (Reuters) - Thousands of Turkish secularists protested outside a court near Istanbul on Thursday against the trial of nearly 300 people charged with attempting to overthrow Prime Minister Tayyip Erdogan's Islamist-rooted government.
Security forces wielded batons and fired pepper spray to keep crowds behind barricades in front of the courthouse at the sprawling Silivri prison complex, where dozens of the defendants have been in jail for much of the four-year trial.
Those in the dock include politicians, academics, journalists and retired army officers accused of membership of a shadowy underground network of ultra-nationalists.
The alleged group, "Ergenekon", is accused of orchestrating decades of political violence, extra-judicial killings and bomb attacks, and most recently of trying to topple Erdogan.
Rivalry between religious and secular elites is one of the major fault lines in Turkish public life. The case is emblematic of Erdogan's long-standing battle with secularist opponents, and one of a series of conspiracy trials that he describes as a struggle against anti-democratic forces.
State prosecutors were set to present their final statements later on Thursday.
Erdogan's critics say the trial is part of efforts to stifle opponents of his AK Party (AKP), whose strong strain of religious conservatism they see as undermining Turkey's secular foundations. There were calls for the government to resign among slogans chanted by the crowds.
"TURKEY IS SECULAR!"
"Turkey is secular and will remain secular!", "The AKP will have to answer to the people!", "Shoulder-to-shoulder against fascism!", chanted the crowds.
They were largely made up of members of the main opposition CHP, a smaller left-wing party whose leader is one of the defendants, and secularist associations.
Many in the crowds waved Turkish flags and pictures of Mustafa Kemal Ataturk, who founded a modern, secular Turkish republic from the ashes of the Ottoman Empire in 1923.
During his decade in power, Erdogan has transformed Turkey, creating a thriving economy and taming a powerful military that had ousted four governments in recent decades.
But the Ergenekon case and other conspiracy trials have drawn accusations of political influence over the judiciary, with the CHP describing them as an "Inquisition" against opponents of the government.
"These courts are like Russian dolls. They may look like different cases and different courts, but they are all the same. They are carrying out a political mission," CHP deputy leader Umut Oran, who was attending the hearing, told Reuters.
The 275 defendants, 66 of them in custody pending a verdict, include former armed forces chief Ilker Basbug and two deputies from the CHP. Once prosecutors have summed up their case, the defendants will have a right to a final statement which, given their numbers, could still take months. (Writing by Daren Butler; Editing by Nick Tattersall and Kevin Liffey)