Former Scottish secretary Alistair Carmichael first revealed the full truth about his involvement in leaking a confidential memo five days after the general election, a court has heard.

The Liberal Democrat MP said he "explained the full background" when he was interviewed for the official inquiry into the leak on May 12 this year.

The Orkney and Shetland MP also told a court he thought it was "politically beneficial" for the memo concerning First Minister Nicola Sturgeon to be leaked.

Mr Carmichael was giving evidence on the first day of a four-day Election Court hearing taking place at the Court of Session buildings in Edinburgh.

Four of Mr Carmichael's constituents are behind a court bid to oust him after he admitted allowing the leak of the memo which wrongly claimed Ms Sturgeon wanted David Cameron to remain in Downing Street at May's general election.

Mr Carmichael initially denied having prior knowledge of the memo leak, which emerged around a month before voters went to the polls on May 7. But he later admitted he had allowed his special adviser Euan Roddin to release details of the document, which appeared in the Daily Telegraph on April 3.

The court heard how a Cabinet Office inquiry into the leak was launched shortly after the newspaper article was printed.

Mr Carmichael told the court he was "less than fully truthful" with the inquiry initially.

"I felt I could truthfully answer, 'No, I didn't leak it'," he told QC Jonathan Mitchell, acting for the four petitioners.

The lawyer said it was only because Mr Roddin had used his own phone to contact the newspaper that an evidence trail emerged.

But Mr Carmichael denied misleading the inquiry and told the court: "The inquiry has to find evidence and put evidence to the people."

The court also heard how those with knowledge of the memo had to fill in a questionnaire for the inquiry.

"You are obviously at this stage not coming up with the truth of the matter, are you?" asked Mr Mitchell.

"I was not giving the full truth," Mr Carmichael replied.

He told the court he ultimately accepted responsibility when he was interviewed for the inquiry.

Mr Mitchell put it to him: "On the 12th of May you go to a face-to-face interview. At that point you say for the first time 'I did it, I'm the person'."

The MP replied: "I explained the full background, yes."

Mr Mitchell then suggested Mr Carmichael had therefore "managed to keep the ball in the air until after the election".

"No," replied Mr Carmichael.

Mr Carmichael told the court he had believed leaking the contents of the memo to be politically beneficial and in the public interest.

He said: "There is a widely-held view that it is in the interest of the Scottish nationalists in achieving their aim of independence for there to be a Conservative government at Westminster.

"It clearly reinforces the narrative that Scotland is so completely different from the rest of the UK that there is a need for us to be independent."

Earlier, fellow Liberal Democrat politician Tavish Scott branded the legal bid to unseat Mr Carmichael a "political show trial".

The Shetland MSP said: "I think people don't like these proceedings. They think it's a political show trial.

"They think it's a political event being funded by people, particularly nationalists, who do not want opposition in this country".

He made the statement during sometimes heated exchanges with Mr Mitchell.

The court heard how, in a local newspaper article dated May 27, Mr Scott, 49, was reported as giving his backing to the "embattled" Mr Carmichael.

In it, he was reported as being "disappointed" by the actions of his party colleague and felt "let down".

Mr Scott, the Scottish Lib Dem leader from 2008 to 2011, told the court: "The best idea is not to lie in politics."

The legal challenge - funded via a crowd-funding appeal - is the first election petition brought in Scotland for 50 years.

The petitioners argue Mr Carmichael's actions call into question his integrity as an individual and his suitability to represent the constituency at Westminster.

Earlier, one of the group of four behind the action told of her shock that Mr Carmichael had told a "lie" over the memo leak.

Orkney resident Fiona Grahame, 57, a member of the Scottish Green Party, said she had respected and trusted Mr Carmichael, who worked hard in the community.

She said: "I was very shocked actually. This was really hard to get your head around - (that) someone you had trusted and respected so much, and had such an important position in Scotland as well, would do such a thing as lie; lie to the people of Orkney and Shetland."

Explaining her position, she said: "I'm not so much complaining about the leak as about Alistair's denial of involvement with the leak."

The hearing before Lady Paton and Lord Matthews continues on Tuesday.