Under-fire Alex Salmond has insisted an independent Scotland would remain part of Europe as it negotiated the terms of its membership.

The First Minister said if there was a Yes vote in next year's referendum Scotland would be "negotiating its position from within the European Union" - citing a letter from the European Commission in support of this.

Opposition leaders at Holyrood had challenged him on the matter after the Spanish prime minister suggested that Scotland would have to apply to join the European Union as a new state.

Labour's Johann Lamont, Tory Ruth Davidson and Liberal Democrat Willie Rennie all attacked Mr Salmond on the matter at First Minister's Questions.

Ms Lamont went on the attack, saying: "The Spanish prime minister is being straighter with the people of Scotland than the First Minister."

She added: "This is an amateurish and shameful attempt by Alex Salmond to mislead the people of Scotland.

"It seems that Alex Salmond is basing Scotland's future on his ability to Google."

Spanish prime minister Mariano Rajoy said yesterday that if part of an existing member state became independent, it would be ''left out of the European Union (EU) '' and would need to apply for membership as a new state.

''If part of a member state becomes independent, it would be left out of the European Union and it would be good for citizens (in the EU) and Scots to know that," he is reported to have said.

Mr Rajoy added this meant "EU entry would need to be approved by all 28 member states".

But Mr Salmond said: "The difference is Scotland would be negotiating its position from within the European Union."

The First Minister then cited a letter from the European Commission, which he said stated it would "of course be legally possible to renegotiate the situation of the UK and Scotland within the European Union".

He said that was "reasonably substantial evidence that Scotland as a nation can negotiate its position to full membership within the European Union."

Mr Salmond told MSPs that the Spanish prime minister had began his statement by stating he did not yet know what the Scottish Government's independence White Paper "which was presented by the Scottish president" had said on the issue.

The First Minister added: "I'm not a president, I'm a first minister and Scotland is not a region, Scotland is a nation."

Ms Lamont also quoted Mr Rahoy, telling the SNP leader the Spanish prime minister had said: "I would like that the consequence of that secession be presented with realism to Scots.

"Citizens have the right to be well informed and particularly when it is about taking decisions like this one.

"I know for sure that a region that would separate from a member state of the European Union would remain outside the European Union and that should be known by the Scots."

The Labour leader told how the president of the European Commission, Jose Manuel Barros, had previously said Scotland would have to reapply to join the EU, adding: "Now the Spanish prime minster agrees with him.

"But in Salmond's world, they're wrong."

She continued her attack, saying: "I used to say to my children 'what you want is not necessarily what you get'. The First Minister needs to understand it's not simply his assertion that matters here, it is what people are entitled to do."

Ms Lamont went on to describe the independence White Paper as being "like an Argos catalogue but without the prices", adding it was "truly historic" as no other document had "become obsolete quite so quickly".

The Labour leader blasted: "What it says about keeping the pound is just plain wrong. Now we know what it says about the Scotland staying in the European Union is just plain wrong.

"What does it say about Scotland when Scots have to listen to a foreign government to find out the truth?"

Mr Salmond said there were three key questions to answer over whether Scotland could negotiate terms of EU membership from within the organisation.

He added: "Can that happen legally, would it happen and can the process be completed within 18 months, the time between the referendum in September 2014 and Scotland becoming a new, separate nation in March 2016?"

He cited a letter from Mario Tenreiro, a head of unit within the European Commission's secretariat general, which stated: "The ongoing democratic process is a matter for the UK and Scottish governments and the Scottish people, and as you say it would of course be legally possible to renegotiate the situation of the UK and Scotland within the European Union."

Mr Salmond said that showed Scotland could "legally" negotiate a deal from within the EU.

He then went on to cite Sir David Edward, a former judge of the European Court of Justice, as having said European member states "would be obliged to enter into negotiations before separation took effect".

The First Minister went on: "Thirdly and crucially could the process be completed within the timescale? I've cited the European Commission, I've cited Sir David Edward, let's cite someone who the authority of cannot be questioned by the Better Together parties, that is Professor James Crawford, the person who was appointed and paid by the UK Government to dispense the legal advice on this matter."

Mr Salmond said when asked "specifically" about this Prof Crawford had described that timetable as "realistic".

He went on: "So, if we have the European Commission, the Court of Justice's Sir David Edward and the person appointed by the UK Government to say the timetable is realistic, I think that is reasonably substantial evidence that Scotland as a nation can negotiate its position to full membership within the European Union."

He insisted Scotland "with its huge natural resource base, would be welcome in the European Union".

Referring to David Cameron's plans for a referendum on the UK's EU membership in 2017, Mr Salmond said: "Scotland is a European nation, we want to be a European nation. The only question about our membership is what is coming from the Conservative Party, many of whom want to get out of Europe."

Miss Davidson continued the criticism of SNP approach to EU accession.

"It shows just what a shower of rank amateurs the SNP Government is when it comes to international diplomacy," she said to a chorus of jeers from the Nationalist backbenches.

"The SNP says they're right and everyone else is wrong on Europe.

"They say that the commission president is wrong when he says that Scotland would have to join the same queue as everybody else.

"They say that the Spanish prime minister is wrong when he says that Scotland would have to join the same queue as everybody else.

"They say that the foreign ministers of Spain, of Latvia, of Ireland and the Czech Republic are wrong when they say we would have to join the same queue as everybody else.

"What the First Minister doesn't understand is that it doesn't matter if he gets 15 member states on board, or 25, 26, or even 27. He needs the governments of every single one of 28 countries to agree to his demands.

"Does he think he's winning friends and influencing people by telling them they're wrong?"

Mr Salmond pointed out that Prime Minister David Cameron would need to agree to talks with the European Commission.

He urged Miss Davidson to get on the phone, using reverse charges if needed, to convince her leader to accompany a Scottish delegation.

"The European Commission are prepared to talk to us now but they say they need the permission, and we have to go jointly, with the UK Government," he said.

"We have said to the UK Government, 'why don't we go jointly?', and the UK Government - her political party - say they won't pre-negotiate, therefore they won't go.

"It's not the Spanish veto we've got to worry about, they're not having one. It's the UK Government's veto."

Meanwhile, Mr Rennie said the SNP has shown in the past that it cannot negotiate with just one government.

The First Minister "sold out" on terms when arguing for more powers in the Scotland Act, which transferred new powers to Holyrood, including limited tax responsibilities, he claimed.

"We all remember in this chamber his six red lines on the Scotland Act," Mr Rennie said.

"But he sold out on every single one of them - and that was only negotiating with one government.

"That's why he has been called the worst negotiator in the northern hemisphere."

Mr Salmond replied angrily: "Can I remind you that in negotiations for joining the European Community, as it was then, a civil servant noted bitterly that in light of Britain's wider European interest they, the Scottish fishermen, are expendable. An exact quote.

"I can tell you that for this Government, Scottish fishermen will never be expendable."

Pointing to Mr Rennie's predecessor, Shetland MSP Tavish Scott, he continued: "Let's remember that Tavish Scott had to resign from government in this chamber because he didn't think it was fighting for Scottish fishermen."