By John Knox
Political reporter, BBC Scotland
The scene in the Holyrood counting house was Dickensian.
The finance secretary John Swinney was bent over his calculations.
The Green MSP Patrick Harvie was pleading for a few pennies more for poor people in uninsulated homes.
A Dickensian atmosphere pervaded Scotland's Parliament
Clerks were running pieces of paper to and fro.
MSPs were coming and going like traders on the floor of a crashing stock exchange.
The haggling went on till the very last minute. But when the bell finally rang for voting time, it was 64 for the government's budget, 64 against.
The Presiding Officer, Alex Fergusson, dubbed by one publication this week "The Good Shepherd", announced he would be using his casting vote for the status quo.
That meant the new budget would fall and government departments and councils up and down the country would have to make do with the sums in last year's budget.
It also meant a political maelstrom. All deals were up in the air.
Iain Gray, the Labour leader, asked how he could table a motion of "No Confidence".
Alex Salmond placed his SNP troops on an election footing.
Meanwhile, Mr Swinney tried to calm nerves by saying he hoped to bring a new budget to parliament next week and he would be entering into immediate talks with the other parties to try again to assemble a majority.
By question time on Thursday, Alex Salmond was warning the Labour Party of the dire consequences of not passing the new budget.
"There are 35,000 jobs at stake," he said, "plus the apprenticeship places, and the small business bonus, and the council tax freeze, and the accelerated capital spending, and the town centre regeneration fund, all of these things are at risk because of Labour's attitude."
Iain Gray accused the SNP of hubris, managing to quote Einstein and Shakespeare on the way.
Labour were accused of using the budget as a smokescreen for a coup
"The first minister failed because the SNP approached the serious matter of the Scottish budget with reckless brinkmanship and arrogance," he said.
The Conservative leader Annabel Goldie came to Mr Salmond's defence. She had, after all, led her Conservative 15 onto the field in support of the SNP's budget and won £60m for the town centre fund.
She said: "For Iain Gray and the Labour Party this was not about addressing Labour's recession, this was about staging a debating chamber bloodless coup to ensconce him as first minister."
However, there was a complete change of atmosphere when the Liberal Democrat Tavish Scott stood up to ask his question.
"We need an economic storm rescue plan for the long term," he said. " So, is the first minister prepared to sit down, as I will, to roll up his sleeves and work with others to build a budget, and a long term approach, which will create jobs and tackle the economic recession?"
"Yes", said Mr Salmond, that's what he'd been trying to do all along. But he warned the Liberal Democrats that their idea of a 2p cut in income tax was "not tenable".
As Thursday afternoon wore on, news came through of opposition leaders beating a path to ministers' doors to talk about a deal on the budget. Labour want 15,000 more apprenticeships over the next two years.
The Liberal Democrats want the SNP to engage with the Calman Commission to explore the possibility of borrowing powers for the Scottish Parliament.
And that leaves the Greens. There's been much chewing over whether Patrick Harvie made the right decision at 4.55pm on Wednesday.
A queue of party leaders formed hoping to make a budget deal with ministers
He decided that Mr Swinney's "I will ensure that it happens" was not a sufficient guarantee of the £33m of new money he was demanding for home insulation.
Had he overplayed his hand? Should just two MSPs be allowed to hold the government to ransom? Or has he put climate change on the political map once and for all?
The new round of negotiations - involving all the parties - will go on over the next few days. Mr Swinney hopes to be able to announce a deal by Wednesday when the first stage of a new budget bill has been scheduled for debate.
He reckons there's only £100m in dispute, out of a total budget of £33 billion. The final vote will then take place on 11th February, in time for the new budget to be in place for the new financial year on 1st April.
And in time, just, for councils, health boards and government agencies to fix their budgets for the next year.
With all this excitement going on, there hasn't been much time for other business at Holyrood.
There was a debate on forestry on Thursday morning. Labour and the Liberal Democrats are fighting a plan by the environment minister Mike Russell to lease out around a quarter of the Forestry Commission's forests in Scotland.
Mr Russell says it would raise £200m for investment in new forests. The critics say it would restrict access to the forests and threaten jobs.
The culture minister Linda Fabiani read the first page of her speech in Gaelic, and very good Gaelic it was too, by all accounts.
She announced that under the plan a development officer will be appointed to guide councils and other bodies on how they can promote the language in their areas.
Finally, national Holocaust Day, on Tuesday, was marked in the Scottish Parliament by a multi-media production, "And Then They Came For Me".
Actors and videos told the story of Eva Schloss who survived the Auschwitz concentration camp and whose mother went on to marry the widowed father of Anne Frank. Eva Schloss herself watched the play and answered questions afterwards.
The producers hope to take the play to parliaments across the world, including Israel and Palestine.
What a week it has been! From the agonies of the Holocaust to the brink of disaster over the budget.
Next week, we can only hope for a reconciliation.