• Scottish Secretary Jim Murphy (left), First Minister Alex Salmond (centre) and shadow Scottish secretary David Mundell (right) speak to floor managers as they prepare to take part in Scotland's second live TV debate. Picture: PA
On the eve of tonight's final contest between Gordon Brown, David Cameron and Nick Clegg, Lady Smith said that, with two debates down and one to go, Mr Salmond had left it far too late to contest his exclusion. The SNP's opponents claimed its attempt to appear alongside the main UK party leaders had been a "stunt" and described the decision as a humiliation for Mr Salmond.
At the Court of Session in Edinburgh, Lady Smith refused to grant an interim interdict banning the BBC from broadcasting tonight's debate in Scotland unless it included an SNP representative. She ordered the SNP to pay the corporation's legal expenses.
• Was judge right to SNP's debate case against the BBC?
However, with the party having raised 50,000 to cover the costs of the case, legal sources last night suggested the total bill would fall well short of this, leaving the SNP in pocket.
One senior MSP told The Scotsman last night: "We believe the 50,000 should cover the costs, and we have had several days of high-profile publicity out of this, so we are pleased that Alex went for it, even though the case was lost."
Despite the defeat, some senior figures in the SNP were far from dismayed over the outcome, but the party vowed to continue to fight for a place in future televised leaders' debates.
The judge suggested that the SNP might have been taken by surprise by the impact of the debates, but she was not persuaded that the party had a case of impartiality against the BBC.
The courtroom challenge came after the BBC Trust had rejected an appeal from Scottish and Welsh Nationalists against their exclusion from the debate.
• Election 2010 daily guide: Thursday 29 April
Earlier this week, the SNP raised 50,000 from party supporters in just 48 hours to finance the court case.
In court, the SNP argued that it was "inherently unfair" to exclude the party and was contrary to the BBC's requirement under its charter to show "due impartiality" in election coverage.
However, the BBC argued that the Nationalists' demands were both "impractical" and "ultimately pointless".
After the ruling, SNP deputy leader Nicola Sturgeon said: "Obviously, we are disappointed not to have secured (an interim interdict]. We will now take our case to the court of public opinion. Our experience over the last few days has been that there is considerable support in Scotland for the case we are making, and that is why we were able to raise in excess of 50,000 in a short period of time.
"This case is about an issue of principle… the principle of fairness and the right of one of the main political parties in Scotland to put forward their point of view."
Ms Sturgeon rejected suggestions that the party had gambled away 50,000 of supporters' hard-earned cash. "Today is not the final decision in this case. We will be pursuing the judicial review because we believe there are important issues at stake: issues of fairness and impartiality … which go beyond this debate and this particular election."
• Election 2010: Live blog
Lady Smith said that the BBC's duty of impartiality could not be a simple matter of giving each and every political party equal coverage. It took into account such matters as prior electoral support.
She noted that the BBC had planned coverage of the SNP's campaign, which "appears to be of substance and cannot be said to be lacking in impartiality". The BBC told the court that, because of technical difficulties, if broadcasting were banned in Scotland, then the debate might have to be scrapped.
Lady Smith said it was relevant to consider whether the SNP had delayed in seeking the interim interdict. The party had known since last December that prime ministerial debates were planned. "The reality may well be that the petitioners (the SNP] have been taken by surprise by the nature of the apparent impact of the debates thus far, but that is beside the point. There is no satisfactory explanation advanced as to why they did not take action prior to the first debate," the judge stated.
Lady Smith said that delay in this case was particularly significant. She said also that the SNP's tactic of calling for the third debate to be blocked would deprive the public from being able to view the entire series of debates.
"It would, on the face of matters, leave them with an incomplete picture. That would hardly accord with proper, well-ordered administration," Lady Smith said.
In a further setback for the SNP, broadcasting regulator Ofcom yesterday announced it has not upheld its complaints that the first of the three debates was misleading and impartial.
Labour's Holyrood leader, Iain Gray, said: "This was a desperate attention-seeking stunt by a party who have nothing to say in this election. But it ended in humiliating failure for Alex Salmond.
"He must be the only person in Britain who thinks this election is about how many times he appears on television. It is about jobs and the economy."
David McLetchie, the Scottish Conservative election campaign manager, said the legal action was "desperate stuff" and "no more than a 50,000 SNP campaign stunt".
The Liberal Democrats' Scotland Office spokesman, Alistair Carmichael, said the case was a waste of time and money.