The castle saw even more people at this year's St Andrew's weekend
An open weekend to mark St Andrew's Day in the year of Homecoming attracted almost 12% more people to Edinburgh Castle than last year.
St Andrew's Free Weekend, which was held for three days from 28 November, drew 24,810 visitors compared to 22,169 last year.
The Historic Scotland weekend event was also a hit across the country with 39,700 people visiting 47 attractions.
This compared to 35,000 in 2008, an increase of 11%.
The Historic Scotland Free Weekend was a key part of both the St Andrew's Day celebrations and the finale of Homecoming Scotland 2009, which was inspired by the 250th anniversary of the birth of Robert Burns and was an invitation to Scotland's people at home and abroad to reconnect with the country.
In keeping with tradition, Edinburgh Castle was also open on St Andrew's Day itself, 30 November, so people could view the crown jewels and the Stone of Destiny.
Barbara Smith, Historic Scotland's executive manager of Edinburgh Castle, said: "Having the castle open for three days for free is very special and we were delighted by the number of visitors we welcomed through the gates.
"It was an excellent opportunity for people to enjoy the heritage at the heart of their own community for free."
Other sites in the Lothians which took part in the free weekend were Linlithgow Palace, Blackness Castle, Craigmillar Castle, and Dirleton Castle and Gardens, Tantallon Castle and Trinity House.