Last week David Cameron and Nick Clegg made history when they formed a coalition government. But the Conservative - Liberal Democrat deal was not a foregone conclusion. Labour too were very much in the game.
Negotiating teams were locked in talks for five days
For The Report on Radio 4, Linda Pressly talked to negotiators from all three parties to find out how the deal was done.
The first meeting between the Conservative negotiators and their Liberal Democrat counterparts took place on the evening of Friday 7 May. The Chancellor of the Exchequer, George Osborne, was one of the Conservative team.
"We were all tired because we'd had almost no sleep," he said. "But we knew this was a big moment, and we got down to business pretty quickly.
"And my impression of the team Nick Clegg had assembled," he added, "was that here were four people of serious intent who wanted to sit down and come to some kind of coalition agreement."
But even on Friday, there was behind-the-scenes manoeuvring between the Liberal Democrats and Number 10.
By Saturday, Gordon Brown was assembling a potential Labour team to talk to the Liberal Democrats.
Ed Balls, the former schools secretary who had only just hung on to his seat in the general election, got a call from the prime minister about a secret meeting that took place in Portcullis House that afternoon.
"It was absolutely deserted. We went in a lift to the third floor and had an hour's discussion with the Liberal Democrats.
"The tenor of the meeting was formal and distant, but we didn't interpret that badly," he remembers. "We said it would be very hard to pull this off, and although there were red lines in our manifesto we wouldn't cross, at the same time, if they were serious, we would be willing to support electoral reform," said Mr Balls, who has now entered the contest to be the next Labour leader.
But Andrew Stunnell - a member of the Liberal Democrat team, and now the Parliamentary Under Secretary of State at Communities and Local Government - was not impressed: "It wasn't a very satisfactory meeting. I don't think the Labour team saw it as a discussion between equals.
"They approached it as if they were Secretaries of State dealing with a minor party," he said. "They didn't seem to grasp the fact they were out if they didn't do a bit of serious work."
Over the weekend and on Monday morning, although formal talks continued between the Conservatives and the Liberal Democrats, there was a major sticking point: electoral reform.
George Osborne was very aware of this. He thought that "if we couldn't offer anything on electoral reform to the Liberal Democrats, then Nick Clegg would be in a very difficult position, because his party would expect him to deliver something. So he would be tempted to stitch something together on the Labour side."
During Monday, events moved fast. The Parliamentary Liberal Democrat party asked their negotiators to talk to Labour.
Negotiations were scheduled to begin on Monday evening.
Meanwhile the Conservatives were forced on to the back foot. The Cameron leadership team knew they had to make a substantial offer to the Liberal Democrats. There was a meeting of the shadow cabinet, followed by one of the parliamentary Conservative Party.
Then the Conservatives played their ace - an offer of a referendum on the Alternative Vote. That Monday evening, they got positive soundings from the Liberal Democrats on this.
George Osborne remembers that "we knew things were back on with the Liberal Democrats because we were able to make an offer on electoral reform, and although they were having formal talks with the Labour Party, actually the very serious option they were considering was a Conservative - Liberal Democrat coalition."
Meanwhile, those talks on Monday evening between Labour and the Liberal Democrats were going badly.
Treasury Chief Secretary David Laws negotiated for the Liberal Democrats
Lord Adonis, the former Transport Secretary, was on the Labour team. He thought that "what the Lib Dems were doing was going through a checklist of policy areas telling us what the Conservatives had offered and inviting us to bid higher.
"This was a Dutch auction," he felt, "because what they were seeking to do was not to engage in a serious negotiation with us, but to get from us a set of offers which they could then go back to the Conservatives with."
Is that what the Liberal Democrats were doing?
David Laws, now Chief Secretary to the Treasury, was also in the meeting for the Liberal Democrats. He argues that "half of the Labour negotiating team gave the impression of wanting things to work, half gave the impression of not being so committed, in terms of body language and response. They seemed to be looking for problems not solutions."
There was little improvement in the tenor of the meeting between Labour and the Liberal Democrats on Tuesday morning.
Both Liberal Democrat and Labour negotiators said they knew it was over by the end of that meeting.
By Tuesday afternoon the Liberal Democrat team were heading back to the Cabinet Office to finalise a deal with the Conservatives.
A lot of commentators thought the Liberal Democrats had done very well from the agreement.
George Osborne does not see it like that: "A coalition was a much stronger arrangement than a minority Conservative government. And a minority government would have struggled to pass all its programme - so every single night in the House of Commons we might have been defeated on education reform or welfare reform, or deficit control which is crucial.
"As it is we get all that during this parliament," he adds, "but we're also going to implement some Liberal Democrat policies.
The Report was on BBC Radio 4 on Thursday, 20 May at 2000 BST. You can also listen via the BBCiPlayeror download the podcast.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.