Scotland's economy rebounded in the first quarter of this year, boosted by growth in production and services.
Official figures showed GDP grew by 0.8%, having shrunk by 0.2% in the previous three months.
Scotland outstripped the UK as a whole, which saw growth of just 0.2% in the first three months of the year.
Both the Scottish and UK governments welcomed the figures which saw Scottish production grow by 3.1% and the services industry expand by 0.3%.
However, construction contracted by 0.7%.
On an annual basis, the Scottish economy grew by 0.7%. Equivalent UK growth was 2%.
Some economic forecasters had warned that Scotland could slip into technical recession following contraction in the final quarter of last year.
Reacting to the latest data, Economy Secretary Keith Brown said the figures "reinforce the fact that the fundamentals of Scotland's economy are strong".
He said: "Since late 2014 our growth rate has been impacted significantly by the fortunes of the North Sea with around two-thirds of the slowdown in 2016 attributed to the onshore impact of lower oil prices.
"Today's figures show a rise in output in industries linked to the North Sea for the first time since 2014.
"While there is no room for complacency, these figures - alongside a number of recent business surveys - indicate that there is growing confidence in the sector."
Mr Brown added: "Manufacturing output is also up, in part due to the resumption of steel production at the Dalzell plant after the Scottish government intervened to save this key strategic asset.
"The reopening of Dalzell is just one of the actions the Scottish government is taking to boost manufacturing - we are also supporting the expansion of the aluminium smelter at Lochaber and the development of a new manufacturing centre in Renfrewshire."
Scottish Secretary David Mundell described the figures as "very encouraging".
He said: "The Scottish economy is returning to growth and I am pleased to see that the manufacturing sector in particular is making the most of export opportunities. Scots economy rebounds in first quarter
"But, over the year, Scotland has continued to lag behind the UK as a whole - so there is still a lot of work to do.
"The Scottish government has extensive powers at its disposal to grow and support the economy and these figures underline the need for our two governments to work together as we prepare to leave the EU."
What is Scotland's economy made up of?
- Percentage breakdown based on 2013 figures
Scottish Labour's economy spokeswoman Jackie Baillie said: "It is a huge relief that Scotland has avoided recession, but this was a narrow escape for our fragile economy.
"The long-term trend paints a worrying picture of Scotland's economic performance, with the average annual change of just 0.5% - a quarter of the UK-wide growth.
"The rise in output from industries linked to the North Sea is very encouraging, but recent history should have taught the SNP the danger of relying solely on this sector."
A leading economic forecaster said the figures were "welcome progress" but added that policymakers would be "hoping for a few more quarters of growth at this pace before they are reassured".
Prof Graeme Roy, from the Fraser of Allander Institute at the University of Strathclyde, said: "While production output is up over 3% this quarter, it is still down -4.2% over the past two years.
"And taken with the contraction of -0.2% in the overall economy at the end of last year, and very weak growth during the earlier part of 2016, output in Scotland has still been weaker than the UK as a whole.
"So on balance, these data do not change the fact that the Scottish economy still faces a fragile outlook - particularly when you factor in likely effects of possible higher inflation and any Brexit uncertainty in the months to come."
Business leaders also welcomed the figures.
Scottish Chambers of Commerce said they represented the best quarter of growth for the Scottish economy since before the effects of low oil prices began to emerge in 2015.
Chief executive Liz Cameron said: "This is a huge sigh of relief for our economy.
"The most significant contributor to this recovery has been the production sector and this reflects the positive signals that we have been detecting from Scotland's manufacturers over recent months and, indeed, the returning signs of confidence from the oil and gas supply chain."
The Federation of Small Businesses called the figures "encouraging" but said the country needed to be put on "a much stronger economic footing".
Scottish policy convener Andy Willox said: "We need to develop diverse local economies, so that a single local closure or industry challenge doesn't hit a community, or the entire country, for six."