It has the elements of a thriller: a shadowy group of right-wing former soldiers, a mafia don, extremist lawyers and politicians; hand-grenades in a rucksack; plots to kill the Prime Minister and a Nobel-prize winning writer; allegedly planted evidence and falsified wire taps.

Even the name of the villains - the Ergenekon network - has an airport paperback flavour, and the stakes involved are high: the stability of one of the world's most strategically important countries. This highly charged political reality is splitting Turkey.

In the coming days the Ergenekon investigation will reach its climax. According to newspaper reports, a long-awaited indictment will be issued by the state prosecutor. After successive waves of arrests, 47 people are in custody. They include senior figures in the ultra-right-wing Workers' Party, a dozen retired senior army officers, journalists and a lawyer accused of launching legal attacks that drove Nobel award-winning writer Orhan Pamuk from his homeland.

Crimes being blamed on Ergenekon include a series of murderous bomb blasts, a grenade attack on a newspaper, the murder of an Italian bishop and the killing last year of Turkish Armenian journalist Hrant Dink - all aimed, investigators believe, at creating a climate of terror and chaos propitious to a military coup that would depose Turkey's moderate Islamist government.

The coup attempt has revealed deep divisions in Turkey's 73 million-strong population over the country's identity: pro-European or anti-European, fiercely nationalist, ethnically homogeneous and militaristic, or globalised and pro-Western, more or less Islamic, more or less sunk in historical bitterness and dark conspiracy theories.

'The cleavage is deep: every institution, every social class, everybody is divided,' said Professor Murat Belge of Bigli University, Istanbul, an analyst. 'I am deeply apprehensive about what is going on now and what might happen.'

But for Mehmet Demirlek, a lawyer defending a colleague accused of being a key member of Ergenekon, the allegations are 'imaginary'. 'There is not a shred of truth in them,' he said. 'This is 100 per cent political. It has all been cooked up by the government and by the imperialist powers, the CIA, Mossad and the Jewish lobby and the European Union to eliminate Turkish nationalism. There is no such thing as Ergenekon.' His imprisoned client, Kemal Kerincsiz, told The Observer in an interview prior to his arrest he was a 'patriot fighting the disintegration of the nation'.

For Fethiye Cetin, a lawyer representing Hrant Dink's family, Ergenekon has 'existed for years'. 'A small part of what has been previously hidden is being exposed. Call it the "deep state".'

An investigation was launched by state prosecutors after 27 hand-grenades, said to be the make used by the military, were found in a home in a rundown part of Istanbul last June. Investigators claim that they later uncovered an underground network dedicated to extremist nationalist agitation.

Wire taps led to further finds of explosives, weapons and documents listing security arrangements of senior political and military figures and death lists. The papers supposedly proving Ergenekon - the name of a mythic mountain in Asia where the ancestors of the Turkic peoples escaped the Mongols - was set up in 1999 as a clandestine and violent organisation aimed of maintaining a reactionary, purist vision of a strong, militaristic Turkey, the heritage, the extremists believed, of the founder of the nation, Kemal Ataturk.

The plotters tap 'into a psyche that is based on a new and extreme nationalism', said Cengiz Candar, one of Turkey's most prominent journalists. 'The idea is that to preserve Turkey it is necessary and legitimate to resist in any way. And anyone who is pro-European, liberal, who argues for increased rights for minorities and so on is a traitor.'

According to Candar, this new nationalism is the result of a coincidence of factors: the difficulties of Turkey's accession to the European Union, soul-searching over nation identity generated by the debate on Europe, the emergence of a strong, semi-autonomous Kurdish state in post-Saddam Iraq with all the potential implications that has for Turkey's large Kurdish population, and, perhaps most importantly, the continuing electoral success of the AKP, the Justice and Development party, the moderate Islamist party led by Recep Tayyip Erdogan to power in 2002. 'With no way of ousting them through democratic means, other means become attractive to the extremist nationalists. This country has a long tradition of such actions,' said Candar.

Turkey's political history has been marked by interventions by the army, each preceded by a period of violent instability and each justified by the need to preserve the constitution and the nation. The repeated electoral success of the AKP, its social and economic policies, its pro-European, pro-free market stance, the growth of newly wealthy, religiously conservative middle classes who vote for Erdogan and his colleagues and the party's break with Turkey's fiercely secular ideology - all threaten the nation's powerful military and bureaucratic establishment.

A legal bid to ban the party - on the grounds that it wants to impose Sharia law on Turkey and thus overturn the constitution - is one tactic, AKP party loyalists say. Violence and the activities of Ergenekon is another. 'How long are these people going to keep their power when it is incompatible with a European, fully democratic Turkey?' asked Belge. 'And how big is Ergenekon? Who are they? How high does it go?'

No official military spokesman would comment but General Haldun Solmazturk, who retired three years ago, told The Observer 'the Ergenekon group is trivial, barely worthy of attention', saying that though 'it was possible' a few military officers might have become involved in the group, the vast majority of Turkish soldiers were 'committed to maintaining democracy'.

Solmazturk, who said that his own views 'reflected those of most senior soldiers', insisted 'there are far more grave problems facing Turkey than a handful of right-wing crazies'. Instead, he said, it was the government that worried him. 'The AKP are a concern. There is no such thing as moderate Islam. Either a government is influenced by religion or it isn't. And if it is, then it is not secular and not democratic,' he said. 'We want to move democracy forward, they want to move it back and we are approaching a point of no return.'

In a rundown working-class suburb of Istanbul, far from the tourist sights of the historic centre, the deputy chairman of the Nationalist Action Party in the city, Nazmi Celenk, made an effort to show his party's moderate side. 'In Turkey we are on the front line of the clash of civilisations,' he said. 'We are the natural allies of America and Britain in this region. Our future is in Europe - but not necessarily in the European Union.'

Yet Celenk was critical of last week's reform of Turkey's strict rules on 'insulting Turkishness', pushed through parliament in the face of fierce resistance from the 70 deputies from his own party. If he was in power, Celenk said, the tight laws on freedom of expression would be maintained. And, if he had the power, he would invade Syria and split the state between Turkey and Iraq. The violent Kurdish activism in the south-east of his country would be solved 'in 24 hours'.

A street away, a group of mechanics and local shopkeepers played backgammon. They said they were worried by rising crime, drug use and low wages, but would not vote for the nationalists. 'They try and cause fights between us to get votes,' Hikmet, a bus owner, said.

Fethiye Cetin, the Dink family lawyer, is still optimistic despite the tensions. She discovered her own minority roots - an Armenian grandmother - at the age of 25. 'This period is the peak of aggressive nationalism in Turkey, but there is still peace,' she said in her small office on a hill above the blue waters of the Sea of Marmara. 'But everyone always focuses on the negative side and never on the tens of millions who live together without any trouble at all.'

Victim of the plot?

Hrant Dink was a 52-year-old journalist, assassinated in January 2007. As co-founder of Agos, a newspaper published in both Turkish and Armenian, he became a prominent member of the Armenian minority in Turkey and pushed for Turkish-Armenian reconciliation and human rights.

Dink was shot in Istanbul by Ogün Samast, a 17-year old Turkish nationalist. 100,000 mourners turned out to Dink's funeral to chant: 'We are all Armenians'.