An independent Scotland would have its own security service to fight international threats such as terrorism, cyber attacks and serious organised crime, the Deputy First Minister has told a Westminster Committee.

The current Scottish Government would seek to establish its own intelligence agency while working closely with agencies in the rest of the UK, such as MI5 and MI6, Nicola Sturgeon told the Foreign Affairs Committee at a meeting in Edinburgh.

Challenged on the cost of setting up such an organisation, Ms Sturgeon told the committee the Government is undertaking work covering the issues of set-up costs, running costs and co-operation with the rest of the UK.

"In terms of security and intelligence, I would envisage Scotland having an independent domestic intelligence machinery in Scotland, sitting alongside our police service, but working very closely, given our sharing of an island, with the rest of the UK," she said.

Asked by Conservative MP Rory Stewart what strategic threats she envisaged an independent Scotland facing, Ms Sturgeon said, in common with other nations, the country could be at risk of "cyber threat, international terrorism, global instability, the possibility of failed states and serious international organised crime".

Mr Stewart went on to quiz the Deputy First Minister about the costs involved in establishing an intelligence agency.

"The UK has inherited an enormous amount of embassies. It's devoted billions over decades to develop a very sophisticated infrastructure," he told her.

"There would have to be a very considerable investment to set it up."

Ms Sturgeon replied: "We are doing a substantial piece of work on some of this just now."

Asked if Scotland would expect to be able to read the rest of the UK's secret intelligence, Ms Sturgeon replied: "There are arrangements with other countries ... I think there would be a very close relationship between Scotland and the rest of the UK.

"Scotland and the rest of the UK share an island. It would be not just in Scotland's interest for there to be very close intelligence sharing with the rest of the UK, it would clearly be in the interest of the rest of the UK as well."

Mr Stewart continued to press Ms Sturgeon on the implications of establishing a security service.

The infrastructure needed to fulfil requirements such as "protecting the identity of agents" would require "probably billions of pounds of investment", and this would be necessary before Scotland's allies "would be happy to share information", he said.

Ms Sturgeon said: "There would be a capability that we would seek to have from day one of independence, there would be a capability that we would develop over time and there would be continued shared arrangements with the rest of the UK regardless of our independent capability because that makes sense, based on our geography."

Scotland currently contributes to the cost of running and maintaining the UK's international embassies and FCO network, and it would seek to have a "physical, on-the-ground presence" similar to other small nations, she told the committee.

"I am not suggesting simply dividing physical assets into respective shares, but clearly there would be a share of the UK's assets that Scotland would have an entitlement to in order to contribute to the cost of our own organisation," she said.

The committee's evidence session in Edinburgh was its fourth and final session investigating the foreign policy implications of independence before the Scottish Government's 2014 referendum.

The Deputy First Minister was also questioned on a range of other issues such as Scotland's membership of the European Union, currency, immigration and border control, Trident and nuclear weapons, Nato and international trade.

Ms Sturgeon told the committee that the current Scottish Government would not negotiate on the removal of Trident nuclear weapons from Clyde Naval Base.

Asked by Tory MP Sir John Stanley about the possibility of a UK Government leasing the base, the Deputy First Minister said: "We would not be in a position of accepting that kind of arrangement. We have a principled opposition to Trident nuclear weapons."

Asked about Scotland's membership of the EU, and issues such as joining the euro and becoming part of Schengen, the agreement which allows freedom of movement across Europe, Ms Sturgeon said: "We will be arguing in the case of Schengen, as in the case of the euro, continuation of the status quo. We wouldn't be asking for any change in our relationship with Europe in this respect.

"We are not in Schengen at the moment, we would simply be saying we did not want to go into Schengen. And whether you take that as a legal position or as a political position of common sense, it would seem to be a fairly strong argument to be making."

The committee also heard from Tory MP David Lidington, a UK Foreign and Commonwealth minister, who criticised the Scottish Government's approach to security.

"If Scotland were to be an independent state, Scotland would have to consider how she was going to substitute for those United Kingdom arrangements," he said.

"The costs of doing so would be enormous, particularly to start up such agencies from scratch.

"In general terms, smaller European countries do not have the security apparatus on anything like the scale of professionalism that we have in the UK."

The role of security and intelligence was of "vital significance" during the Olympic Games in London, he said

After the hearing, he estimated that it costs about £2 billion a year to run the UK's security agencies.

"It's not only a matter of costs of employing people, headquarters, communications, all those things, it's a matter of finding people and training them. Expert security people don't just come out of nowhere."

The UK network of diplomacy would also need to be considered, he said.

Scotland is represented through about 270 offices around the world under the present arrangements.

During the hour-long session, he was asked if the rest of the UK would be badly affected by Scotland leaving.

The remainder would cope but would miss the benefits of "soft power" from Scotland, he said.

"We have approached this issue in terms of the mutual benefits that the people of Scotland and the rest of the United Kingdom derive from their common membership of the UK," he said.

"I think that the remaining United Kingdom, if forced to, would be able to cope. I think the burden on an independent Scotland to replace on its own everything that it gets from membership of the UK would be much greater.

"Where the UK does benefit is from what one might describe as the soft power of Scotland: Scottish culture. There is a tradition in Scotland of a global outlook that is respected around the world. Someone like Andy Murray who is very proudly Scottish but was a very proud part of Team GB when it came to the Olympics. Scotland's contribution strengthens the UK as a whole."

Speaking after the committee session, he also questioned the way the SNP is approaching EU negotiations over currency.

New member states are obliged to accept they will join the euro currency while Britain and Denmark have an opt-out.

Mr Lidington said: "What I find extraordinary is any suggestion that an independent Scotland would seek to accept an obligation to join the euro then ignore it, and actually negotiate in bad faith."