Ten sheriff courts and seven justice of the peace courts will close after Holyrood's Justice Committee backed changes to legislation.

Members narrowly voted against Labour proposals to reject two parliamentary orders bringing the closures into effect.

Sheriff courts in Dornoch, Duns, Kirkcudbright, Peebles, Rothesay, Cupar, Dingwall, Arbroath, Haddington and Stonehaven will be closed, with business transferred to nearby locations. Many of these courts also have co-located justice of the peace courts.

Meanwhile, justice of the peace courts in Annan, Irvine, Motherwell, Cumbernauld, Portree, Stornoway and Wick will also shut.

Opposition MSPs said the closures, which were put forward by the Scottish Court Service (SCS) and accepted by the Scottish Government, will mean witnesses and victims will have to travel further to see justice being done while remaining courts may struggle to cope with increased business.

Politicians and business leaders also fear local economies will be affected.

But Justice Secretary Kenny MacAskill insisted the closures were justified as a cost-saving measure and as part of wider reform of the justice system.

He said: "We cannot deliver better access to justice by avoiding the need for change.

"It is right that we examine structures that have served us since the 19th century.

"We recognise that all change has its pros and cons, its advantages and its disadvantages. But on balance our considered view is that this the way forward."

At a meeting of the committee today, four SNP members and independent MSP John Finnie voted against Labour MSP Lewis Macdonald's motion to annul the orders while the remaining four Labour, Conservative and Liberal Democrat opposition MSPs backed it.

Mr Macdonald said: "Justice is not just another commodity to be provided only where there are enough customers to make it sustainable.

"It is surely a matter of priniciple to this committee that local communities the length and breadth of Scotland should have access to justice, and that those accused of serious offences should, where possible, be tried by a jury from their local area, and should certainly stand trial as close as possible to their local community."

Mr Macdonald accused Mr MacAskill of attempting to deflect responsibility for the closures.

"Responsibility for these cuts is his and his alone," he said.

"He says that Lord Gill (Scotland's most senior judge) has to stand in front of him and take some of the responsibility, but of course he also concedes that the reason Lord Gill is in the position he is in is because the budget that Kenny MacAskill has provided to the court service has been cut and cut so dramatically."

During the meeting, members of the committee were joined by five Labour MSPs for a lengthy and often heated debate of Mr Macdonald's proposals.

Opposition politicians urged SNP members to back the motion to annul, which would have resulted in the orders for the closures being brought before the full Parliament.

Conservative MSP John Lamont called on them to "defy their party and stand up for constituents".

He said: "The closure of so many courts will harm access to justice, they will pass on costs to victims and witnesses, will result in increased delays and therefore increased costs, they will divert cases to some of Scotland's busiest and least efficient city courts and they will result in the loss of significant business and footfall away from regional towns across Scotland."

Independent MSP John Finnie said he had been persuaded to back the closures.

He said: "I don't think any of us would choose to be in the position we are in here. We are here because of unionist cuts, that's not in dispute.

"On a personal level, the easy decision for me would be to say 'Let's pass it on (to the full Parliament)', but the reality is that we wouldn't be passing on decisions that were seen to be favourable."

SNP member Roderick Campbell has previously spoken of his concern about the closure of Cupar Sheriff Court, which is in his constituency.

He voted against Mr Macdonald's bid to halt the closures today. He told the committee the SCS has vowed to keep the administration of justice in Fife under review.

"I regret that, in a number of discussions, I have failed to change the Cabinet Secretary's mind as to the closure of the court in Cupar. I remain of the view that that's bad news.

"I accept however that the statutory instruments we are required to consider today refer to a lot more courts than just Cupar Sheriff Court."

Christine Grahame, committee convenor and SNP MSP, said she had been pesuaded by Lord Gill's evidence to the committee.

She has campaigned against the closure of Peebles Sheriff Court in her constituency.

"When I hear the senior judge in Scotland telling us this is the way forward, with the other issues built in which we can keep reviewing, I have to say I moved from being very sceptical to saying I think the man has made his case," she said.

Speaking after the meeting, Liberal Democrat MSP Alison McInnes said: "Today's vote marks the beginning of the end for local justice in Scotland.

"SNP members of the committee have shown complete contempt for their constituents in voting to close down local courts in Cupar, Stonehaven, Peebles, Haddington and around the country. To make the argument to save their local courts and yet blithely vote for the Government demonstrates a complete lack of respect."

The Law Society of Scotland, which represents solicitors, said today's decision will harm access to justice.

President Bruce Beveridge said: "Today's decision by the Justice Committee is a big disappointment. This will be a major loss, particularly for our rural communities.

"Local courts are an integral part of communities across Scotland.

"In addition they make a significant contribution to the economic activity in their local communities and we're not convinced that this was fully considered before today's decision.

"Of course we recognise the financial pressures facing the Scottish Court Service and understand that change is necessary.

"We all want a justice system that is fit for the 21st century but, while we are largely in favour of the proposals on wider court reform, we remain concerned that this closure programme will fail to provide proper access to justice or achieve significant financial savings in the long term."

Parliamentary orders for the closures will come into effect on June 29, with courts shutting between November this year and January 2015.