The figure from the National Statistics Institute was 64 percent higher than in 2020, when the pandemic decimated the travel sector worldwide as countries imposed lockdowns and closed their borders.
But it remained 63 percent below the 2019 figure, when 83.5 million tourists visited Spain, the world’s second most popular destination after France.
The government had hoped to see 45 million foreign visitors in 2021.
Spain’s tourism industry accounted for 12.5 percent of its economy before the pandemic. The figure fell to just 7.4 percent last year, according to the Exceltur tourism association.
British tourists, who before the pandemic made up the biggest national group of visitors, only numbered 4.3 million in 2021.
The French became the biggest contingent last year with 5.8 million visitors, up 49 percent from 2020, followed by the Germans at 5.2 million, an increase of 117 percent.
The official figures show tourists spent 34.8 billion euros in Spain last year, or 76 percent more than in 2020, but 62 percent less than in 2020.
Tourism Minister Reyes Maroto highlighted the figures from December when 2.9 million tourists visited Spain, despite the “uncertainty generated by Omicron”, the highly-contagious Covid variant which has been sweeping Europe.
“The sector will consolidate its recovery in 2022,” she said.