By Erik Kirschbaum and Elisabeth O'Leary

BERLIN/EDINBURGH (Reuters) - Scottish First Minister Nicola Sturgeon met the deputy foreign minister of Germany on Tuesday, seeking to strengthen her ties with Europe's economic powerhouse in the wake of Britain's vote to leave the EU - a move Scotland overwhelmingly rejected.

Sturgeon has said that Scotland, where 62 percent of voters backed staying in the European Union, must not be dragged out against its will and that she would start preparing for independence to keep Scotland's post-Brexit options open.

The surprise visit to establish contact with Berlin may not, however, sit well with some European countries, such as Spain and France, that have been wrestling with regional separatist movements and are opposed to holding any direct talks with Scotland on the terms of Brexit.

"The situation in Scotland won't be repeated anywhere else, unless Spain suddenly decides to leave the EU and I don't think that will be the case anytime soon," Sturgeon told Germany's ARD TV, dismissing those fears.

"Scotland is in a unique situation... and I think that under these circumstances it's important to stay open for all possible options. And I think that it would be very positive for the rest of the EU if part of Great Britain, if not all of Great Britain, should remain part of the European family of nations."

In what was her first visit to an EU capital as first minister since a meeting with EU leaders in Brussels days after Britain's June 23 EU referendum, Sturgeon met Michael Roth, one of Foreign Minister Frank-Walter Steinmeier's top deputies and also Germany's European Affairs Minister.

"Today's discussion has been a welcome and constructive opportunity to strengthen our relations to discuss the way forward for the European Union and how all voices can be heard in that process," Sturgeon said in a statement in Edinburgh.

"Scotland chose to remain in the European Union, and the solidarity shown toward Scotland as an enthusiastic part of the EU - demonstrated once again in today's talks here in Berlin – has been very welcome."

The meeting, however, did not take place at the German Foreign Ministry, which declined to say where it was held.

Sturgeon set out the perspective of Scotland, whose resounding vote to stay in the EU was overridden by Britain's overall 52-48 percent outcome in favor of leaving.

The head of Scotland's devolved nationalist government has vowed to explore all the possibilities for Scotland to stay in the EU despite the referendum result.

In a statement on the German Foreign Ministry website, Roth said: "We had a very pleasant and constructive conversation between two passionate Europeans. I hope that the United Kingdom will find a way forward so that at the end of the day Europe will profit as a whole."

Sturgeon has said that a second Scottish independence referendum is a possibility because of the divergence of the EU vote. But she has argued that Scotland may not have to give up its EU membership even if it stays part of the UK.

(Additonal reporting by Andreas Rinke; writing by Erik Kirschbaum; Editing by Hugh Lawson/Mark Heinrich)