In the headlines, the thwarting of a transatlantic terror plot. Playing out behind the scenes in Whitehall, a story that the government doesn't want you to read. An intense internal battle is being waged over how to respond to terrorism without compromising fundamental principles of justice and civil liberties. It is dividing the intelligence services, splitting the cabinet and has left David Cameron and Nick Clegg in a state of alarmed semi-paralysis. It is a big test of the unity of their partnership, their leadership mettle and their willingness to honour the promises they made in opposition.

A commitment to liberty is supposed to be the essential glue that binds the Tories and the Lib Dems. An early token of that was the decision to cancel identity cards. ID cards were unpopular and they were expensive. So that was an easy way to make a united assertion of their liberal credentials and honour manifesto commitments. A much harder challenge is striking the right balance between preserving civil liberties and protecting the public from terrorism. In opposition, the Conservatives and Liberal Democrats were agreed that New Labour got that balance very wrong: core human rights were too often sacrificed in the name of the fight against murderous fanatics. The result was too much anti-terror legislation which was unjust, ineffective and counterproductive.

When they reached government, they commissioned a review. To oversee this review, they appointed Ken Macdonald, the former director of public prosecutions, who is now a Liberal Democrat peer. That appointment was taken as a signal of intent to repeal or reform those laws that are most offensive to the principles of justice. The former DPP was a particularly potent critic of "control orders" and 28-day detention without charge.

Control orders are a form of house arrest for alleged terrorist suspects who are confined without charge for indefinite periods on the basis of secret material which it is virtually impossible for the accused to challenge. Courts have delivered a series of stinging judgments which have struck down the validity of orders. As well as undermining the presumption of innocence, control orders have failed to protect the public from individuals who may be genuinely dangerous. An embarrassingly significant proportion of controlees have absconded. In opposition, the Lib Dems were robust. Every year that the legislation came up for renewal, they voted against. Nick Clegg condemned the "control order regime" in these terms: "It removes the pressure to charge and prosecute the criminals whom we all want to see apprehended. It diverts energy and attention away from other important innovations that we should be examining to strengthen our criminal justice system, and it infringes the most fundamental principles of due process and human rights." The Liberal Democrat manifesto pledged to abolish control orders on the grounds that: "The best way to combat terrorism is to prosecute terrorists, not give away hard-won British freedoms."

The Conservatives have historically been divided between their authoritarian impulses and their liberal tendencies. The Tories abstained on the renewal votes. But they, too, repeatedly expressed opposition to control orders. Pauline Neville-Jones, a former chairwoman of the Joint Intelligence Committee who is now the security minister, told the Lords that the Conservatives would take office "with the aim, if we possibly can, of eliminating the control order regime". Dominic Grieve, now the attorney-general, described them as "a departure from our established principles [which] threaten our liberties greatly".

No other state in the world that can be called a democracy gives the police the power to hold terror suspects without charge for anything like as long as 28 days. When that legislation was passed five years ago, it was justified on the grounds that it was essential in order for the police to deal with complex plots. In fact, 28 days has been activated just three times. In one case, the charges were dropped; in a second, the accused was acquitted on the direction of the judge; in the third, the accused was acquitted by the jury. It is another draconian provision which corrodes Britain's reputation for justice while offering no palpable advantage in the struggle against terrorism. Even some of the architects of this legislation are repenting. Tony McNulty, security minister in the last government, now says that control orders and 28-day detention should be scrapped.

The assumption was that the coalition would do this after it appointed Lord Macdonald. But here's the rub. The review may be associated with him, but it has actually been conducted by the Office for Security and Counter-Terrorism, a unit based in the Home Office staffed by active or former members of the security services. The head of MI5, Jonathan Evans, wants to keep control orders. He used a speech last month to lobby publicly for the governing parties to break their promises to the voters. One senior figure with a ringside seat for this battle remarks: 'This is what they always do. When Jonathan Evans eyeballs the prime minister and says, 'I can't guarantee that the public will be safe from terrorism if you don't give me this', it is hard for the prime minister to stand up to that."

The head of MI5 does a vital and difficult job. He knows a lot more than most of us about the nature of the terror threat. But that shouldn't make him the supreme arbiter of the balance between protection and civil liberties. Nor is he an infallible authority on the appropriate policy response to terrorism. Mr Evans's predecessor at MI5, Eliza Manningham-Buller, took the opposite view: she was deeply sceptical about control orders and downright hostile to extended detention without charge.

The Evans line has prevailed within the Home Office. The review has gone to ministers with the recommendation that control orders should be retained. It proposes that detention without charge should be reduced to 14 days, but with an option for suspects to be put on a further 14 days of "very restricted bail", which would introduce the control order concept into another part of the law.

The review's conclusions were supposed to have been made public at the end of September. Then publication was kicked back to the end of October. That is because weeks of fierce internal argument have resulted in deadlock. Lord Macdonald has not changed his views. He recently warned the home secretary that he will write a dissenting report. This has put Theresa May in a funk. A surprise choice for home secretary, she came to the job with no history of engaging in the delicate judgments the role demands. She has already signed off on two new control orders. Insiders believe an inexperienced home secretary has been easily captured by securicrats who are always reluctant to give up powers once they have them. She has come down on their side, but knows it will be hugely embarrassing for the government if it publishes their recommendations only for Lord Macdonald then to denounce them. Ms May went to Number 10 a fortnight ago for a difficult meeting with David Cameron and Nick Clegg. When she revealed that they had hit this impasse, both men were horrified. David Cameron told the meeting: "We are heading for a fucking car crash."

So they are. And it will be a multiple pile-up, for this question also profoundly splits the cabinet. The Lib Dems around the table pledged to abolish control orders and they have Tory allies. The justice secretary, Ken Clarke, hasn't budged in his opposition. Mr Clarke has been round the Whitehall block several times in his long career. He has been home secretary. He is not intimidated by the heavy breathing of the head of MI5. He understands that politicians should be attentive to the advice of the security services, but not slaves to them. Nick Clegg knows that he will look terrible and his party will be in uproar if he dishonours the pledges he made in opposition. One colleague describes the Lib Dem leader as "caught in the headlights". David Cameron, scared of rupturing his coalition, yet fearful of over-ruling the securicrats, is just playing for time. I have learned that the publication date for the review has been put back yet again towards the end of the year.

There is a route out of their dilemma. That is to stick to their promises, scrap control orders, charge those suspected of terrorism in open court and lift the ban on the use of intercept evidence to give prosecutions a better chance of success. To resistant members of the security agencies, the prime minister should say, and will have the support of many professionals in saying it, that they ought to concentrate on the intelligence-led approach to countering terrorism which has proved to be the most effective method of stopping bombers.

To do otherwise would be to betray their promises and the belief in liberty which is supposed to be the animating and binding value of the coalition. If they cannot hold true to their pledges on such fundamentals as justice and human rights, it will be hard to resist the conclusion that they can't be trusted with anything.