Former Scottish secretary Alistair Carmichael has told a court he "enormously" regrets his involvement in the leaking of a confidential memo.

The Liberal Democrat MP made the statement as he gave evidence for a second day at a special Election Court sitting in Edinburgh.

During the hearing, he also admitted he tried to mislead a Cabinet Office probe into the leak.

But the Orkney and Shetland MP denied lying about his role in the release of the document to protect his reputation.

Four of Mr Carmichael's constituents are behind a court bid to oust him from his seat - brought under Section 106 of the Representation of the People Act 1983, which forbids people from making false statements about the character and conduct of an election candidate.

It comes after he admitted responsibility for the leaked memo written by a civil servant, which incorrectly claimed First Minister Nicola Sturgeon told the French ambassador that she would prefer to see David Cameron remain in Downing Street at May's general election.

The MP initially denied having prior knowledge of the memo leak, but following a Cabinet Office inquiry he later admitted he had allowed his special adviser Euan Roddin to release details of the document, which appeared in the Daily Telegraph towards the start of the election campaign on April 3.

Questioned by his own counsel Roddy Dunlop QC, Mr Carmichael, a married father-of-two, told the court it has been "a difficult few months" for him.

"Do you regret getting involved in this in the first place?" asked the lawyer.

"Enormously," Mr Carmichael replied.

Earlier, the court heard Mr Carmichael's claim in an April Channel 4 interview that he had no prior knowledge of the leak was "false".

Mr Carmichael told Jonathan Mitchell QC, acting for the four petitioners, that he had initially denied knowledge of the leak to protect Mr Roddin and the interests of his party.

"We were still wanting to keep the focus on the story and not on the leak," he told the court.

The MP agreed the focus would have moved to him if he had initially admitted knowledge of the memo leak.

Mr Mitchell suggested that would have been "destructive" of his reputation, but Mr Carmichael insisted: "It was nothing about my reputation."

The QC continued: "You're assuring the court this is nothing to do with protecting your reputation?"

Mr Carmichael replied: "The question of my reputation was not the consideration that we had. This was about keeping the focus on the political story, the purpose of the leak in the first place."

On Monday, Mr Carmichael told the court he was "less than fully truthful" with the Cabinet Office inquiry initially, which was launched shortly after the newspaper article was printed.

Mr Mitchell today suggested the MP's approach to the probe was "calculated and intended to mislead".

Mr Carmichael replied: "Yes, I would have to accept that."

The court later heard from political expert Professor John Curtice, of Strathclyde University.

He talked the court through the picture which faced the political parties ahead of this year's general election, based on polling data.

On the prospects for the Lib Dems in Scotland, he told Mr Dunlop: "It was always anticipated that given the apparently calamitous result for which the Liberal Democrats were headed... that Orkney and Shetland was probably about the last man standing."

Mr Carmichael subsequently became his party's only elected MP in Scotland.

The witness described the Orkney and Shetland constituency as "unusual" given the length of time over which the Lib Dems have retained electoral support there.

Asked by Mr Mitchell whether it could have been taken as a "racing certainty" that the seat would be held by the Liberal Democrats in 2015, he said: "It would be regarded as a very substantial shock if the Liberal Democrats were to lose the constituency. Shocks do, however, occasionally happen."

Asked whether the trustworthiness of a candidate can be a factor in elections, he replied: "Undoubtedly one of the things voters will take into account is the extent to which they can trust the candidate in question."

The legal challenge is the first election petition brought in Scotland for 50 years.

The hearing before Lady Paton and Lord Matthews continues on Wednesday, when lawyers for both sides are expected to make their submissions to the court.