The artwork, titled "Game Changer", fetched more than four times the estimated price Christie's auction house had set.
The black and white painting first appeared at Southampton General Hospital on the south coast of England during the first wave of the pandemic in May 2020.
It depicts a child playing with a doll that resembles a nurse, dressed in a cape and striking a pose like superman, while other superheroes lie in a basket next to him.
The one square metre piece was hung in collaboration with the hospital's management near the emergency department.
Hospital chief executive Paula Head tweeted at the time: "So proud to reveal this amazing piece of art ‘Painting for Saints’, created by #Banksy as a thank you to all those who work with and for the NHS and our hospital."
“An inspirational backdrop to pause and reflect in these unprecedented times,” she added on Twitter.
The anonymous artist left a note with the piece saying: "Thanks for all you're doing. I hope this brightens the place up a bit, even if it's only in black and white."
The artwork's auction price far surpassed Banksy's previous record for the oil-on-canvas painting "Devolved Parliament", which sold for £9.9 million (€11.5 million at the current rate) in 2009.
The auction took place one year after England was put under a nationwide lockdown in a bid to fight COVID-19.
The Twitter account NHS Million, a campaign run by the health service's staff that aims to find a million people who are grateful for it, thanked Banksy in a post.
This is not the first coronavirus-related work created by the Bristol-based artist since the outbreak of COVID-19.
In April 2020, he posted snaps of rats he had drawn causing havoc in his bathroom. The caption read: "My wife hates it when I work from home."
And in July, he used the London Tube as his canvas, this time sharing a video on his Instagram account featuring an individual, assumed to be him, dressed in the same uniform as the cleaners who have been drafted in to disinfect the underground during the COVID-19 crisis.
The individual ushers away passengers as he spray-paints rats in various guises relating to the pandemic on the walls of the carriages using a stencil.
Banksy rose to prominence in the 1990s and his work usually has political connotations, decrying hunger, poverty, racism or the plight of migrants and refugees.
Some of his latest works have focused on the United Kingdom's exit from the European Union and the Israeli-Palestinian conflict.
In 2018, he famously destroyed one of his own artwork right after it had sold in an auction for $1.4 million (€1.3 million).