Photos showing the Take That star meeting Armed Forces personnel and performing a live concert were posted on Twitter by friends and family of the soldiers back home.
Twitter user Sarah Hunt tweeted: "@GaryBarlow Wanted to say Thanks for visiting my sister & all in Afghanistan. Lifts their spirits no end!" with a picture of the makeshift concert attached.
Barlow was filming an hour-long TV special for ITV, expected to air in December.
An ITV spokeswoman told the Mirror: "Owing to security restrictions it would be inappropriate to release further information."
Last year the singer was appointed an OBE for services to music and charity, including climbing Kilimanjaro for Comic Relief and organising the Children in Need Rocks concert.