An expert working group commissioned by ministers has said the Scottish Government does not have to wait until the budget is in surplus to establish an oil fund.
Norway was in deficit when it established its fund in 1990 and it is now worth £470 billion, the Scottish Government Fiscal Commission Working Group's report on stabilisation and savings funds points out.
Deficits are not unusual, according to the experts who point to official predictions that the UK deficit will last 50 years and indicate that 28 of the world's 35 most advanced economies are forecast to be in deficit next year.
The Better Together campaign to keep the Union argues that governments "can't save money while you are borrowing money" and say that an oil fund would "wipe out one-third of the health budget".
But Mr Swinney said it could be done without extra taxes or cuts as revenues saved when the oil price is high would be deferred for the years when it falls.
Speaking at the launch of the report at Heriot-Watt University's Institute of Petroleum Engineering in Edinburgh, Mr Swinney said: "The commission envisages the creation of two funds. The first is a stabilisation fund to deal with the short-term fluctuations based on a cautious oil price in our budget forecasts. Our view of a cautious forecast is $113 a barrel.
"The commission say if you have revenues generated, because the price is higher or your production estimates are exceeded, that gives you the long-term ability to manage the fluctuation year-on-year.
"The second argument is for a long-term savings fund which you contribute to when the financial circumstances arise. They make the case that we could be contributing towards stabilisation funds by the end of the decade, and we think that is credible and possible by 2017."
This can be done "without in any way undermining commitments to public expenditure", he said.
"When the debt trajectory is declining, which we expect to be the case by the end of the decade, it will be possible to contribute to an oil fund without there being any diminution of public expenditure," he said.
The experts advise that a cross-party consensus will be required to manage the fund over many years. The SNP plans to set out fiscal rules to govern the fund for the future but it is unclear whether this will form part of its proposal for a Scottish constitution.
Mr Swinney said: "Whether this is an issue that should go into a constitution is a different matter, but what we will have to have and what we will certainly argue for and set out in due course will be a set of fiscal rules that we think are important to govern and discipline the management of the public finances which will give, essentially, a higher status to some of the issues that we are wrestling with on the oil fund."
The Scottish Government will argue for a population share of the UK national debt, but Mr Swinney ruled out recent suggestions by the National Institute of Economic and Social Research (NIESR) that Scotland could swap its oil revenues for a lower share of the debt.
"We are not interested in the argument advanced by NIESR," he said. "We want to have a responsible negotiation around these issues with the UK Government and take the steps to establish a stabilisation fund and a savings fund."
The Fiscal Commission Working Group said Scotland would have to use oil revenues to fund spending and reduce borrowing in the first years of independence, so it should work towards achieving "some form of onshore budget balance" in the short term.
"Given the need to restore the public finances to health following the substantial deficits of recent years, a strict surplus rule would mean that there would be relatively few opportunities to invest in an oil fund in future years," the report states.
"However, the working group believes that there is merit in the government of an independent Scotland investing a proportion of its North Sea revenues in an oil fund whilst in deficit.
"The near-term economic outlook will constrain the size of deposits that can be made into a Scottish stabilisation fund.
"Scotland's fiscal position is likely to improve in the coming years as the economy recovers. However, given the fiscal position that Scotland is expected to inherit, it is possible that in the coming years Scotland, like the UK, will remain in budget deficit. This would not be unusual. The International Monetary Fund forecast that 28 of the 35 advanced economies it monitors will be running a budget deficit in 2014.
"The latest forecasts by the Office for Budget Responsibility also estimate that, based on current trends, the UK will be in deficit in each of the next 50 years."
The experts point out that Norway was in a downturn, with high unemployment and a budget deficit, when it set up its oil fund in 1990, meaning money was deposited in the fund and immediately withdrawn to prop up the budget.
"However, the Norwegian economy subsequently rebounded and the first modest net transfer to the fund was made in May 1996," it said.
"The country's oil fund is now worth around £470 billion, making it the largest sovereign wealth fund in the world."
Better Together leader Alistair Darling said: "Common sense tell us that you shouldn't borrow money and save it at the same time. It would be the equivalent of taking out a loan to put the money into your savings account.
"The report today kicks the idea of an oil fund into the long grass. Even they admit that Scotland would have to run a surplus before we could create a fund and that is unlikely in the years immediately following independence. We could not afford it without big tax rises or big cuts.
"What is new and significant in this report today is their suggestion that Scotland would need a separate 'stabilisation' fund in order to deal with the fact that an independent Scotland would be dangerously reliant on volatile oil revenues. It sounds fair enough until you remember that even in the years of highest oil prices in the last decade, Scotland has still run a fiscal deficit."
Yes Scotland chief executive Blair Jenkins said: "The recommendations by these internationally renowned economists represent an opportunity to use this great asset sensibly and usefully and to avoid the huge mistakes made by successive Westminster governments in the past."
Liberal Democrat leader Willie Rennie said: "Hidden on the footnotes of the experts' report we learn that Alex Salmond's oil fund could wipe £3.4 billion off of public spending. That's one-third of the health budget for the whole of Scotland."
Chief Secretary to the Treasury Danny Alexander said: "The North Sea is a great asset that is best managed across the whole of the UK, given the volatility and uncertainty of receipts.
"Even with oil revenues, Scotland still spends more than it raises. So while the SG (Scottish Government) appears to want to put one half of oil revenues in a short-term stabilisation fund and the other half in a long-term fund for future generations, upon independence it would need the whole lot just to keep the country running.
"The Scottish Government need to explain what other cuts to spending or tax rises they are proposing to pay for its fund.
"Independent estimates of future oil revenues predict a substantial decline. The Scottish Government needs to set out how it will deal with this, especially now that HMRC's new estimates of Scottish North Sea receipts over the past decade are lower than the Scottish Government's estimates by an average of £600 million per year; the same problem we see with the Scottish Government's optimistic forecasts for future oil revenues."
Labour finance spokesman Iain Gray said: "So now the SNP tell us they are not just going to have an oil fund, they are going to have two oil funds.
"The first of these, the stabilisation fund, is an outright admission of what economists have been telling the SNP for months, and what John Swinney told his cabinet colleagues in private: a Scottish economy would be dangerously exposed to the volatile fluctuations of price and production of oil and gas.
"As for the second 'sovereign wealth' fund, John Swinney still cannot tell us when he would be able to invest because even he knows that you cannot use oil revenues to prop up public spending and save at the same time.
"Norway may save in its oil fund but it makes choices to allow that. For example, Norwegians pay to visit a GP, pay for most prescriptions and pay the full cost of services from dentists and hospital specialists. Are these the kind of choices Mr Swinney envisages to allow him to start an oil fund?"
Conservative finance spokesman Gavin Brown said: "The Scottish Government, not content with one oil fund, has now decided it wants to set up two.
"As the SNP knows fine well, an independent Scotland would be projected to be in an inferior financial position by 2016, something John Swinney himself noted in his leaked document. This means we would need to use all the oil revenues to finance current spending levels and even with that, there would be a huge gap.
"How on earth the Scottish Government would then be able to put money into not one but two oil funds when there is a considerable budget deficit is a mystery.
"The SNP's entire financial case rests on hoping that oil ceases to be volatile and constantly retains a very high price."
MSP Patrick Harvie, co-convener of the Greens, said: "While the idea of building up a fund from Scotland's energy assets makes a great deal of sense, it's astonishing that the Fiscal Commission has not one word to say about the urgent need for transition away from fossil fuels.
"If the Scottish Government is remotely serious about its own stated commitments on climate change, it must accept, as the Climate Change Minister appeared to yesterday, that the oil and gas industry is immensely overvalued and ending our reliance on it is both an environmental and an economic imperative.
"Scotland is already generating substantial energy from renewables and as wave and tidal schemes come online through the 2020s, this will grow significantly.
"We should be focused on how to harness the economic benefits of the whole energy sector for the greatest public benefit. As a finite commodity, fossil fuels can only offer economic benefits for the next few decades. We must think ahead, and renewables are the key to that."
SNP MSP for Aberdeen Donside Mark McDonald, a member of Holyrood's Economy, Energy and Tourism Committee, said: "Anti-independence politicians now acknowledge that some of the North Sea's vast revenues could and should have been saved in an oil fund.
"But successive Westminster governments have used this resource as a short-term cash cow to be squeezed at every opportunity to prop up the Treasury's crumbling books. Apart from the UK, only Iraq among the major oil-producing countries doesn't have an oil fund, and even Iraq has a form of development fund.
"The truth is we are still less than halfway through the wholesale value of oil assets to be extracted from the North Sea. We know Norway only established its oil fund in the 1990s, when the fiscal circumstances allowed, and this has grown to become the largest sovereign wealth fund in the world.
"With the right handling, Scotland's oil and gas industry can continue to thrive for many decades to come and will best do so in an independent Scotland."