Scots are very good at heroic defeats - in football, on the battlefield and in elections.

But the challenge for Scotland after the independence referendum is to realise what they have won, which is more difficult.

It is easy to indulge in the consolations of victimhood, of "we wuz robbed"; to look for conspiracies and perfidious enemies in the Westminster establishment, the press, the banks. But the real way to get at the corporate bullies and anglocentric politicians is to expose their weakness, not your own.

Scotland made a very dramatic statement last week. Despite being clubbed over the head for two years with threats of economic apocalypse, 1.6 million voters asserted their democratic right to say they wanted to live in a better nation. The people of Scotland turned their referendum into a festival of democracy, with unprecedented levels of voter engagement - sparking what been described as "a glorious revolution" by Guardian commentator, Jonathan Freedland, which could transform the entire UK.

It was a near-death experience for the British state and the world watched in fascination. The political and financial establishment was rocked to its foundations. 55% to 45% may seem a comfortable margin, but this result was only secured after the UK party leaders had been forced to sign a vow that Scotland would achieve further substantial political and economic autonomy within the UK.

The promise, as described by Hero of the Union (First Class) Gordon Brown, was unequivocal: "A system of government as close to federalism as you can have in a nation where one part forms 85% of the population." It was a belated commitment to devo max - the option wiped from the ballot paper, which Scotland's voters put back.

Democracy seems such a rough and ready, chaotic way of managing political change, yet it has a habit of finding the right answers at the right moment. History will judge that Scotland's voters, having been offered an impossible question, somehow managed to come up with the right response. Thursday's vote undermined the legitimacy of the British state without actually triggering independence.

The Westminster establishment had given voters here what they believed was an offer they couldn't refuse: give up on this self-determination nonsense or suffer economic and political isolation.

Of course, it is true that Scotland is a very wealthy country and capable of becoming a successful independent nation like Norway. But without co-operation from Westminster, this would be a rocky road for the first few years. Scotland would have had to build up currency reserves to bolster its central monetary authority. It would have been relieved of its share of UK debt, but the act of exclusion might have made its cost of borrowing high.

So, voters here were handed a gun and invited to shoot themselves with it. But the gun backfired. It turned a crisis for Scotland into a crisis for the UK state. The entire UK is now in a condition of constitutional ferment, with regions and nations demanding autonomy.

David Cameron has tried to harness Scotland's devo max to a system of English Votes For English Laws - effectively to create a de facto English parliament within a parliament. Labour has rejected this, on the grounds that the party could become the government of the UK and be out of power in England, 85% of it. Despite what Brown said yesterday, as the "guardian of the promise", this has blocked the legislative timetable promised by all three parties. The vow may have started as a cynical ploy to buy off Scotland, but it is now a matter of record and cannot be effaced.

The specific pledge which appeared on the front pages last Tuesday comprised a guarantee of the continuation of the Barnett Formula for public spending, a promise that the NHS here would not be undermined by privatisation south of the Border, that the Scottish Parliament would be entrenched as a sovereign entity and that it should acquire extensive new powers over taxation, borrowing and welfare. Cut out and keep.

Moreover, a binding legislative timetable was offered to reassure Scots that this was a serious offer. As a result, the UK Government is now committed to delivering a draft bill by January, and a second reading before the start of the 2015 UK General Election. This timetable, Scotland was assured, was set in stone. What is not set in stone is what the bill should contain.

Now, of course, many in the independence movement say that The Vow is not worth the paper it's printed on, you can't trust the UK state, parcel o' rogues etc. This is entirely the wrong response, as First Minster Alex Salmond realised with great clarity when he made the most eloquent and politically resonant resignation statement that I have ever heard. Scotland's people now have a sheet of blank paper to write their future on.

Salmond said this situation was "redolent of political opportunities" for the nationalist movement and for Scotland. "Hold their feet to the fire" became a slogan that we will hear for many years to come. He timed his departure to signal that a new generation had taken over Scotland after the Yes campaign. This not just a metaphor but a statement of demographic fact: the 45% were young, multicultural and radical.

The job of writing Scotland's future falls to the Scottish political parties. They will have to conduct intensive negotiations, because no element in Scottish civil society can be excluded. The three unionist parties each have different proposals for devo max. The Liberal Democrats have long argued for full-scale federalism and the Scottish Conservatives have spoken of devolving income tax to Holyrood. Labour has committed only to devolving an additional 5p in the pound of income tax and setting a new top rate. Somehow, these plans must be knitted together.

This takes Scottish politics into new and uncharted territory. But it is surely the proper place for Scotland to be: autonomous within the overall wrapper of the United Kingdom. Most people in Scotland have always said they want federalism, not formal separation, but a significant chunk of them voted tactically for independence the better to secure a new UK. As Professor Tom Devine said at the Sunday Herald's Bloody Scotland conference yesterday: "The future is either federalism, or another referendum - either way the UK state is dead." Not bad for a week's work.