Jim McGovern tried to claim the fare from his Dundee West seat to a Labour party meeting in Glasgow by saying it was the first leg of a two-part trip to Westminster.
But the Independent Parliamentary Standards Authority (IPSA) rejected his expenses claim, arguing the detour was unconnected to McGovern's official work as an MP.
Last month, in the first case of its kind since new legislation was brought in after the 2009 expenses scandal, McGovern appealed IPSA's decision to a tribunal and lost.
IPSA has now revealed its bill for defending McGovern's appeal was £27,000 – which ultimately falls on the taxpayer. McGovern's costs were met by his union, the GMB.
IPSA said each side in the appeal had to pay its own costs, and it would not pursue McGovern for its £27,000 bill. The SNP last night called for McGovern to reimburse IPSA for its legal bill.
The watchdog said it hadn't wanted a tribunal but was glad to have won the test case.
IPSA has now changed its rules on diverted journeys, capping the amount MPs can claim to the standard fare between the start and end points of each journey.
McGovern claimed £23.90 for a single rail fare from Dundee to Glasgow in September 2011 to attend a Labour Party meeting. He then claimed £249.45 for a business class flight on to Heathrow to fulfil his parliamentary role.
McGovern charged both journeys to a card supplied by IPSA, but the watchdog refused to cover the cost of either leg of the trip.
McGovern asked for a review of the decision from IPSA's compliance officer, who agreed the MP should be covered for the cost of the flight, but not the train fare.
McGovern then appealed against the compliance officer's decision to a First Tier Tax Tribunal. However, tribunal judge Roger Berner flatly rejected McGovern's case.
At the tribunal, held in London on March 14, McGovern's counsel admitted that the Dundee-Glasgow leg of the trip could be characterised as not "wholly, exclusively and necessarily in the performance" of the MP's parliamentary function, as the expenses rules require.
However, he said the rules do not dictate that MPs must take the most direct or cheapest route from their seat to Westminster, and it was a fundamental principle that MPs should be financially supported to carry out their work.
Judge Berner said the tribunal did not accept that argument, and it was vital to consider the separate purpose of each leg of the trip.
He said: "In general there can be no duality of purpose - Having found that the travel from Dundee to Glasgow was a separate journey, the only conclusion we can reach is that, as Mr McGovern has agreed, the purpose of that journey was to enable Mr McGovern to attend the Labour Party meeting.
"The expense of that journey was accordingly not necessarily incurred in (or for) the performance of Mr McGovern's parliamentary duties, and cannot be claimed."
McGovern, 56, has been the MP for Dundee West since 2005 and is a member of the Scottish Affairs Select Committee. He has until the end of May to decide whether to appeal the tribunal ruling.
North East Scotland SNP MSP Mark McDonald said: "At a time when many households are struggling to make ends meet, it is unbelievable that Mr McGovern has run up this enormous bill.
"Mr McGovern should reimburse these legal costs himself."
And North East Conservative MSP Alex Johnstone called McGovern's case "extraordinary". He said: "An MP should know the difference between what is a legitimate expense and what is not. I'm disappointed that was not as obvious to Mr McGovern as it is you and me."
An IPSA spokesman said: "We would rather this hadn't gone to a tribunal, but Mr McGovern made the decision to take it there.
"We believe the finding upholds the integrity of IPSA rules in what seems to be a test case."
The Scottish Parliament said MSPs were not allowed to submit a claim "which relates to party political activity".
McGovern said the GMB union was covering his costs, but he did not know how much they were.
"To be honest, I doubt very much if I could afford it. I imagine it would be expensive. IPSA are using public money. I don't use any public money for representation."
Despite bringing the appeal, he blamed IPSA for "digging its heels in" over the fare.
He later said his lawyer had advised him to appeal, and described the SNP's call to repay IPSA as "ridiculous".
He said: "The SNP trying to make cheap political capital out of this does not bear scrutiny."