Alex Salmond's chaotic attempts to persuade voters he could take an independent Scotland smoothly into the European Union have suffered another setback, after Spain said Scotland would need to "join the queue" and negotiate as a new member state.

Foreign minister José Manuel García-Margallo told the Spanish senate on Tuesday that an independent Scotland would have to go through a potentially long negotiating process and win the support of all 27 members, including Spain – directly contradicting Salmond's position on EU membership.

"In the hypothetical case of independence, Scotland would have to join the queue and ask to be admitted, needing the unanimous approval of all member states to obtain the status of a candidate country … and to sign the final treaty [of accession]," García-Margallo said.

Intensifying the pressure on Salmond, the Spanish foreign minister said Scotland would also need member states to scrutinise its legislation before approving the 35 separate chapters that have to be negotiated before a new member is admitted.

In September, the European commission president, José Manuel Barroso, also suggested that an independent Scotland would be seen as a new state, and would need to apply to join.

García-Margallo did not say whether Spain might block Scottish EU membership, but his rightwing People's party government is currently fighting a battle to prevent Catalonia, a wealthy region with significant levels of autonomy, from calling its own independence referendum. Last weekend, Basque nationalist and separatist parties won two-thirds of the seats in its regional assembly, intensifying pressure on Madrid to cede more powers. It now appears the Spanish government's dispute with its own independence movements has led to a hardening stance on Scotland.

García-Margallo's intervention is another significant setback to Salmond, who has endured bruising allegations from opponents and the Scottish press over whether he had lied about receiving formal legal advice from government law officers on EU membership.

Until now, Salmond and his ministers have regarded García-Margallo as a significant ally in their efforts to show that an independent Scotland would be able to freely and smoothly inherit EU membership. They have frequently cited his remarks in January this year, when García-Margallo indicated Spain was neutral about Scotland's future membership.

At the time, García-Margallo said it was "an internal subject which will be resolved within the British constitutional framework, which has nothing to do with the Spanish constitutional framework … they are completely different processes".

Salmond's difficulties escalated dramatically on Tuesday when it emerged his government had never asked for or received any advice from its law officers on whether an independent Scotland would automatically join the EU, after months of hints and apparent confirmation that such advice had been given.

His deputy, Nicola Sturgeon, shocked opposition parties by disclosing the advice had only just been requested, after the Edinburgh agreement setting up the independence referendum was signed by Salmond and David Cameron last week.

The Scottish government has also gone to Scotland's highest civil court seeking to overturn an order from the Scottish information commissioner, Rosemary Agnew, that it should disclose that advice. That legal challenge – due to be heard in December – has now been dropped.

Salmond angrily denied on Tuesday that he had lied in an interview with Andrew Neil on BBC1 earlier this year, when he appeared to confirm his law officers had supported his case that an independent Scotland would join the EU automatically, would not need to join the euro and would inherit the UK's opt-outs on border security, immigration and financial treaty requirements. Salmond insisted he had been speaking in general terms in his BBC interview.

After headlines and leader columns accused Salmond bluntly of "lying", the pressure intensified on Wednesday when the Scottish Tory leader, Ruth Davidson, asked for Scotland's chief law officer – the lord advocate, Frank Mulholland – to appear before the Scottish parliament.

During prime minister's questions in the Commons on Wednesday, Cameron said the situation was "truly baffling" and raised substantial questions about Salmond's assurances on the impact of independence.

"It turns out now they didn't have any legal advice at all and I think what this shows is when you shine the spotlight on the case for separation the SNP put, it completely falls apart," Cameron said.

A Scottish government spokeswoman said García-Margallo's latest remarks had been "overtaken by events" because there was now a deal between the governments to set up the independence referendum. That document, however, makes no mention of EU membership. "As Mr García-Margallo himself said earlier this year, this is an internal matter to be resolved within the UK – and we now have that clear agreement on the process," she said.

She implied the Spanish foreign minister's latest remarks were wrong: "Scotland will inherit exactly the same international treaty rights and obligations as the rest of the UK, as equal successor states.

"Scotland has been an integral part of the European Union for almost four decades, so an independent Scotland will continue in EU membership – and by definition Scotland already meets the criteria for EU membership, as acknowledged recently by an expert report."