Scotland is Brown's testing ground for his campaign against Cameron

Among the dreadlocked, tattooed and multiply-pierced bicycle couriers hanging out in Glasgow's only neo-anarchist cafe, you'll find a few men in suits who don't fit the usual customer profile. There's Lord Gould of Brookwood, the pollster formerly known as Philip Gould, alongside the transport secretary, Douglas Alexander, and Downing Street strategist John McTernan. Picking up a latte at the anarcho-collective coffee house makes good sense: it's just across the road from Labour's campaign HQ for next Thursday's Scottish elections, and all three men are spending a lot of time there just now.

Indeed, Labour's rivals say the party is so fearful of defeat on May 3, it has dispatched a UK cabinet minister to Scotland every week since October. In this closing stretch, you can't move for Labour big guns: in the battlegrounds of central Scotland and Fife, it's Tony Blair one day, Gordon Brown the next.

The anxiety is well-founded. Polling is tricky, given the voting system, but current estimates have the Scottish Nationalists emerging as the largest single party in Holyrood, setting them up to form a coalition with the Liberal Democrats. Labour, for whom Scotland has been rock-solid territory for half a century and which has held power in both Edinburgh and Cardiff since devolution in 1999, would suddenly be in opposition.

How has this happened? Labour insists no tectonic shift toward nationalism is under way. It points to a poll last week that showed, for all the SNP's gains, support for independence down to a measly 22% - the lowest figure in decades. Labour may deserve some credit for that downturn, having spent months hammering away at the core nationalist argument, stressing that in an era of interdependence a standalone Scotland makes no sense.

Yet still the SNP remains ahead. That's surely down to the fact that Scots understand there will be no move towards independence unless they vote for it in a separate referendum, promised for 2010. The Nats are reassuring Scots that an SNP vote next Thursday is for new management in Holyrood, not for an instant break-up of the UK. Scotland will have a chance to see whether it likes the SNP in power before it goes any further. "It's try before you buy," smiles campaign director Angus Robertson.

That cleverly insulates the SNP from any misgivings Scots may have about independence, but it has not removed the national question from the campaign. On the contrary, what's striking to a non-Scot is the constant stress on Scottish patriotism and pride. As if not to be outdone by the SNP, Labour politicians invoke Scottish nationhood again and again. This week they tried to match the SNP's backing from Sean Connery with Alex Ferguson and a raft of Scottish football heroes, all putting their names to a keep-the-union ad in the sports pages of the tabloid papers, declaring: "When Scotland calls, we answer." Labour doesn't like to admit it's on the defensive over nationalism, but one luminary conceded, "There's definitely a contest over who's more Scottish".

In this the SNP is helped by its brand, but patriotism is not the only story. The usual rhythms of politics are also playing out. Scottish Labour is seeking a third term in Holyrood, "and a third term is always a big ask", says one insider. A colleague reckons the SNP is trying to turn May 3 into one big by-election, setting itself up as the receptacle for protest votes from those anxious to give Labour a kicking. The message to Scots angry over Iraq, cash-for-honours, Trident and Blair is that they can vote SNP knowing that "they'll still have a [UK] Labour government in the morning".

There are other factors. Scottish Labour is led by the competent, but unsparkling Jack McConnell while the SNP has the more charismatic Alex Salmond out front. The Nats may have another, less visible advantage. A visit to their unflashy headquarters on an Edinburgh industrial estate affords a glimpse of an extraordinarily focused get-out-the-vote operation. The SNP has spent serious money on the Activate computer system, which enables it to have detailed information - down to shopping preferences gleaned from supermarket loyalty cards - on the Scottish electorate, street by street, house by house. As a result, it has been able to target its mailings with extreme precision: pensioners hear about council tax, students hear about debt - and both are told the SNP is coming to the rescue. If the Nats make serious gains next week, their electoral machine will deserve much of the credit.

All of this is a major headache for Gordon Brown. A bad result next week will bring sniping: if he can't win in his own backyard, how can he hope to win middle England? (Don't blame him, he's not yet the leader, his defenders will reply.) What's more, a First Minister Salmond would surely be in a constant state of friction with a Prime Minister Brown.

Not so, said Salmond when I caught up with him visiting a components factory in Glenrothes. He has fond memories of getting leaflets out with Brown during the (failed) 1979 devolution campaign and reckons they can be colleagues again. The SNP will want to show it can get things done, he says, while Brown won't want rows with Edinburgh leading the evening news every night. "Both of us would have a stake in making things work," he says.

Right now, Brown has a clearer stake in preventing that happening at all. Watching him shake hands with nurses and beam at patients at the Victoria Hospital in Kirkcaldy, you see how he aims to do it - and how he would repeat the trick when he fights a UK-wide general election against David Cameron.

First, he wants Labour to run on its record. He rattles off the stats to show how Scotland has the best employment in the UK and a repaired infrastructure, with schools and clinics that were once crumbling built anew. This has worked, he says; why would you risk throwing it all away?

Second, he strives to expose the contradictions and flaws in his opponents' arguments, on everything from oil revenues to the fate of the pound in an independent Scotland. Do that enough times, with sufficient force, and he believes the enemy will collapse. "It's always like this," he says, recalling previous contests where the SNP started strongly only to fall back. "As the argument becomes clearer, their argument falls apart."

This, I suspect, is how Brown expects to fight the Conservatives. Of course, he will cast himself as the agent of change and as a break from Blair. But he will also remind Britain the way he now reminds Fife of all that has improved since Labour came to power. And he will relentlessly poke holes in the Tories' case, mocking them for presenting themselves as the people to build on a success only made possible by policies they opposed. (That's what he does with the SNP.)

Behind this approach lies a tremendous faith in the power of ideas and argument: present your case, shred your opponents', and you will win. But is politics really like that? Or do other factors - personality, the mood of the times, even the boredom of the voters - matter more? The Scottish elections are a trial run for the kind of campaign Gordon Brown will fight in 2009. Will it work? We will have a few clues next week.

Jonathan Freedland