A legal action challenging the election of Lib Dem Orkney and Shetland MP Alistair Carmichael has failed.
Four constituents raised the action under the Representation of the People Act 1983, claiming he misled voters over a leaked memo before the election.
Judges said Mr Carmichael had told a "blatant lie" in a TV interview about when he had become aware of the memo.
But they ruled it had not been proven beyond reasonable doubt that he had committed an "illegal practice".
Mr Carmichael said he was "absolutely delighted" with the decision to refuse the petition, adding that he recognised there had been a lapse in his conduct.
He described it as a "highly politically-motivated" case.
Mr Carmichael said: "I was always confident that we would win and that has been the basis on which we've approached this.
"But despite that it has been a very difficult, very stressful and very expensive few months for me and the rest of my family."
Tim Morrison, one of the petitioners, said they had won the argument but Mr Carmichael had won the case "on a point of law".
He said: "Alistair Carmichael has been found by the court to have lied to his electorate.
"The fact that he has won has not exonerated him."
A spokeswoman for the Parliamentary Commissioner for Standards confirmed an inquiry into Mr Carmichael was ''ongoing''.
The contents of the memo, published in the Daily Telegraph at the start of the election campaign in April, claimed that SNP leader and Scotland's first minister, Nicola Sturgeon, would secretly prefer Tory leader David Cameron as prime minister rather than his Labour opponent Ed Miliband.
The newspaper said the first minister's comments, reportedly made to the French ambassador, undermined claims that she wanted to build a "progressive alliance" with other left-wing parties.
Mr Carmichael claimed in a Channel 4 TV interview at the time that the first he had heard of it was when he received a phone call from a reporter.
He had in fact authorised his special advisor to leak the memo, an action he admitted days after being elected.
'Out of a job'
Mr Morrison said Mr Carmichael told the Channel 4 interviewer he had not leaked the memo.
"If he had said I am not the kind of person who would make a leak, he would be out of a job today," Mr Morrison said.
"So clearly all political journalists should now ask candidates in elections: 'Are you the kind of person who would do something like that?'
"If they answer that question in a way that is dishonest then they can be done."
Mr Morrison told BBC Scotland all the evidence of the MP's wrongdoing would now be used in a House of Commons standards committee inquiry.
He said: "It is hard to see how he can't be said, at the very least, to have taken the House of Commons into disrepute."
Mr Morrison said 8,000 people had contributed to the crowd-funding of the cost of bringing the court case but it could still end up costing the petitioners an "awful lot of money", especially if Mr Carmichael's costs are awarded against them.
A second petitioner, Fiona Grahame, said she was "shocked" that Mr Carmichael had been proven to be dishonest but because of a "tiny loophole" he was judged not to have broken electoral law.
She said ordinary voters would not understand how "somehow you can tell lies as a politician but that's not to do with you as a person".
BBC Scotland political editor Brian Taylor
So a victory for Alistair Carmichael. But one tinged with critical comment. For example, the judges note his dealings with the Cabinet Office leak inquiry where, they say, his conduct was "at best disingenuous and at worst evasive and self-serving."
Mr Carmichael, however, draws attention to the verdict itself - which confirms that his election was valid within the terms of the law. He says he will now devote his efforts to serving his constituents in the Northern Isles.
There is a further issue. It is understood that Mr Carmichael will now seek to recover his legal expenses from the petitioners - who raised their cash from crowd funding. It is believed those expenses are in the realm of £150,000.
Two scenarios are possible. Either there is an agreement between the parties as to expenses. Or it goes back to court for a ruling.
In the ruling, Lady Paton said Mr Carmichael had told a "blatant lie" in the Channel 4 interview - but that section 106 of the Representation of the People Act did not apply to lies in general.
"It applies only to lies in relation to the personal character or conduct of a candidate made before or during an election for the purpose of affecting that candidate's return," she said.
The judges said they had been left with a "reasonable doubt" about whether the lie could be characterised as a false statement of fact "in relation to [his] personal character or conduct".
They held that his election was not void.
An SNP spokesman said: "As today's determination makes clear beyond reasonable doubt, Alistair Carmichael told a blatant lie to improve his chance of re-election.
"While he prevailed in the election court on a strict interpretation of the law, it is much more doubtful that he or his party will survive the court of public opinion."