The Scottish government was not adequately prepared for the Covid-19 pandemic, according to a new report by the public spending watchdog.
An Audit Scotland report said ministers had been planning for a pandemic - but had based their preparations on flu.
The watchdog also found the government acted quickly to prevent the NHS from being overwhelmed by coronavirus.
Opposition leaders said the failure to heed warnings and prepare better had cost the lives of care home residents.
First Minister Nicola Sturgeon there were "lots of lessons to learn" from the report, but insisted that "the steps we have taken are the right ones".
The watchdog found that despite a number of pandemic planning exercises - in 2015, 2016 and 2018 - not all the actions identified in these projects were fully implemented.
These included measures to ensure access to enough personal protective equipment (PPE) and to quickly address social care capacity.
The report said the government had been "slow" to implement suggested changes in areas that would later become a "significant challenge" during the pandemic.
It stated that ministers "could have been better prepared to respond to the Covid-19 pandemic" and said lessons must be learned.
However, auditors also found that actions such as cancelling non-urgent operations and increasing intensive care capacity had stopped the NHS from being overwhelmed in the first wave of Covid.
There were heated exchanges about the report during Ms Sturgeon's weekly question session at Holyrood, where she defended her government's response.
Scottish Conservative group leader Ruth Davidson said Audit Scotland had set out "in black and white" that the government was "less prepared that it should have been".
She said: "Mistakes were made by this government, mistakes that cost the health of frontline workers, mistakes that cost the lives of care home residents, mistakes that built up over a decade of delay.
"The report makes it plain that her government was warned again and again, there were years where this first minister could have acted."
'Doing my best'
Ms Sturgeon said "a range of national and local pandemic guidance and plans" had been updated in light of the planning exercise - but stressed that they had focused on a flu pandemic rather than the "different beast" of Covid-19.
She said: "However well prepared we were for flu, it became clear quite quickly that we were dealing with something of a completely different nature.
"If I reflect back on the last 10 months I actually think the more valid criticism of the Scottish government and other governments across the Western world is that in the early stages we maybe relied a bit too much on flu preparations, and perhaps hadn't done enough to prepare for the experiences of SARS-type outbreaks."
The first minister also said had "sought to do nothing over the past 10 months other than every single day to do my best and make sure the government was doing its best to steer this country through the pandemic as safely as we could".
Scottish Labour group leader Jackie Baillie said the report "makes clear a pandemic should have been anticipated", and said "lives could have been saved" had warnings been heeded.
She said: "The government knew it could threaten the lives of people across Scotland, they were told the social care system would struggle to cope, and they were warned that access to protective equipment for doctors and nurses simply wasn't good enough. Now we know they didn't act on any of those warnings."
Ms Sturgeon replied that Scotland had "never once run out of PPE", and that her government had "shown leadership" throughout the pandemic.
She said she would look to learn lessons "every day", adding: "Let's engage properly on these things, not just chuck soundbites across a parliamentary chamber."
It is estimated the pandemic will cost the NHS £1.67bn in 2020-21 alone.
The knock-on effects mean there is a "substantial backlog of patients" waiting to be seen in the NHS, according to Audit Scotland.
Stephen Boyle, auditor general for Scotland, praised the "extraordinary commitment" of NHS staff but said the pandemic had "highlighted the need to deal with long-standing health inequalities".
He told Good Morning Scotland that the financial sustainability of the NHS had been under threat for years.
Mr Boyle said auditors had emphasised in a number of reports the importance of longer term planning, and shifting the balance of care away from large hospitals to community-based care.
The government was expecting a pandemic.
It had rehearsed scenarios, carried out table-top exercises and simulations, all of which identified the need to better prepare care homes and to improve stockpiles of PPE.
And despite assessing a flu pandemic as a high risk, the government did not identify it as a stand-alone factor when considering the biggest challenges to the health service.
Scotland is not alone in being caught off guard, and the report points to some of the things that went well.
Speedily increasing the capacity of intensive care and hospital beds for example, and rapidly rolling out the use of digital technology.
But this is the first time we've seen in black and white from an independent body that there were shortcomings in the preparations.
A public inquiry will later look at the decisions that were made.
Dr Lewis Morrison, chairman of the BMA Scotland, said there was "some concern" that the government could have been better prepared, especially when it came to PPE for doctors.
He said pre-existing challenges for the NHS had been "exacerbated by Covid", and that restarting services was going to be a "substantial challenge".
Covid has caused or contributed to the deaths of about 9,000 people in Scotland so far, with those from the most deprived areas or ethnic minorities among the worst affected.
The forecasted £1.67bn cost of Covid in 2020-21 includes £324.5m on PPE and a near 10% rise in staffing costs.
Responding to the report, the Royal College of Nursing said lessons needed to be learned and the "immense pressure" staff had faced for sustained period should be recognised.
It said nurses were concerned about potential long-term risks to their physical and mental health, including PTSD and long Covid.