David Cameron cut a reluctant figure today as he confirmed plans to set up a new press regulator, amid claims the three party leaders had effectively killed freedom of the press.
The prime minister said he had faced down demands for statutory legislation but admitted "two small but important legislative changes need to be made".
An amendment to the enterprise and regulatory reform bill going through the Lords this afternoon will ensure two-thirds of MPs and peers have to agree any future changes to a royal charter, while an amendment to the crime and courts bill will ensure exemplary damages are given to those who fight libel cases outside the regulatory system.
"It is legislation to protect the royal charter, it is not legislation to recognise the royal charter," Cameron insisted
"This is not by any stretch statutory regulation of the press or statutory recognition of the regulatory body."
The prime minister defended his decision to pull out of talks last Thursday, in a move which nearly led him towards what was set to be a damaging Commons defeat tonight.
"These talks were drifting on and on," he told the Commons.
"The move I made unblocked the log jam, which is why we're sitting here today."
The press gallery of the House of Commons was packed during the emergency statement.
Proceedings were also watched from the public gallery by former F1 boss Max Mosley, who became a campaigner against the tabloid press after he was exposed using prostitutes.
Ed Miliband, who enjoyed some of his strongest moments as Labour leader when the phone-hacking on Milly Dowler story broke, seemed far more enthusiastic and even victorious as he gave a speech which poured praise on his own political opponents, including Cameron and Nick Clegg.
The deputy prime minister seemed similarly pleased with the deal.
"It's not a victory for one team, but a victory for working together," Clegg said.
"It's a victory for putting narrow interest to one side, for sticking with it - a proper independent watchdog to protect our free press."
The deal, which was drawn up in Miliband's office at 02:30 GMT this morning, will see a press regulator set up by a royal charter with a "dab" of legislation to ensure ministers or the press cannot later water it down.
The key to the impasse over introducing a statutory underpinning to the regulator was to change the law so it affected all royal charters, rather than one establishing a media regulator in particular.
This allowed it to be introduced without regulation of the press even being mentioned in parliament and prevented ministers or the press being able to alter the regulator's terms without having to establish it by statute.
But it also led to confusing scenes this morning as Tories insisted there was no statutory legislation while Labour and Lib Dem sources argued the precise opposite.
"It's not statutory underpinning. It is simply a clause that says politicians can't fiddle with this so it takes it further away from politicians, which is actually, I think, a sensible step," the prime minister told ITV.
Moments earlier, Miliband had said: "The royal charter will be underpinned by statute. It stops ministers or the press meddling with it."
In a sign of how confusing the proposal became, the prime minister's spokesman told journalists: "What this does is it actually enshrines a non-legislative approach."
The press will not be able to veto appointments to the regulator and it will be able to direct how newspapers publish apologies, including their placement.
The regulator will have the final say over any changes to the code of conduct and wil be able to exercise discretion over which complaints from third parties it takes up.
The deal saves Cameron from what was expected to be a significant Commons defeat this evening. Around 20 Tory MPs were expected to join Lib Dem and Labour MPs in shooting down the Conservative plans for a royal charter.
In a reminder of how the debate on press regulation was triggered, the Sun was forced to apologise to Labour MP Siobhain McDonagh today for accessing her mobile after it was stolen. She is accepting "very substantial damages" from the newspaper.