Gallagher was born in Manhattan, New York City. His mother, Mary Ann (née O'Shea) (August 23, 1915 - June 6, 2004), was a bacteriologist, and his father, Thomas Francis Gallagher, Jr. (June 10, 1912 - November 16, 1999), was an advertising executive. Gallagher is the youngest of their three children. He is of Irish Catholic background and was raised in Armonk, New York. Gallagher graduated from Tufts University, where he was active in theater, appearing in such shows as Stephen Sondheim's Company and singing with the all-male a cappella group the Beelzebubs.