A video posted on Twitter showed the pair belting out a rendition of Abba’s Waterloo at The Fife Arms in Braemar.
Ms Spiteri sings the famous chorus while Dame Judi pretends to play on a pianola, as well as offering the occasional backing vocal.
The Texas frontwoman then feigns shock at the Oscar winner’s musical abilities, mouthing: “What a pianist!”
They shared the piano stool throughout the impromptu performance which followed a dinner and ceilidh at the venue.
- The latest headlines from Scotland
- Man, 81, goes viral on TikTok with impromptu song
Ewan Venters, CEO of Artfarm which owns The Fife Arms, posted the video on social media, and it was soon amassing thousands of views.
He told BBC Scotland the crowd’s reaction to the performance on the hotel’s self-playing piano was “joyful”.
“Judi Dench and Sharleen Spiteri were staying at the hotel and we had an impromptu moment at the piano,” he said.
“It was a happy evening with lots of guests and locals clapping.”
He said the pair burst into song just before the midnight fireworks.
“It was a classic Scottish Hogmanay party at The Fife Arms,” he said.
“The hotel was fully sold out, with four course dinner and a ceilidh with lots of reeling.”