The 'I'm Outta Love' singer joined up with the Take That star, as well as Tulisa Contostavlos and Louis Walsh, during the talent show's Glasgow auditions.
Anastacia told the Scottish crowd: "I'm not sure I'll be able to concentrate on the talent because of Gary Barlow - he's so hot!"
The 43-year-old also flirted with a contestant who took to the stage wearing a kilt.
"So, what you got on under there?" the American popstar asked, to which the auditionee replied: "Why don't you come up here and find out?"
After peeking under the man's kilt, she returned to her seat, proclaiming: "He had nothing on under there! I love Scotland!"
Anastacia is the sixth guest judge of this X Factor series, following Mel B, Geri Halliwell, Nicole Scherzinger, Leona Lewis and Rita Ora.
The auditions round concludes with dates in Cardiff and Newcastle later this month.
> Louis Walsh tells Manchester 'X Factor' crowd to 'shut up'
> Flirty Rita Ora impresses London crowds at 'X Factor' auditions
Photo gallery - Anastacia joins the X Factor panel in Glasgow:
Copyright: Rex Features Ken Mckay/Thames