New Cumnock Primary in East Ayrshire is made up of two schools, Castle and Cairnhill, merging in the building of the former Castle Primary where he learned his first lessons.
The millionaire was greeted by the headteacher who joked that Sir Tom has an oustanding library book fine of £20,000.
During the visit Sir Tom announced how he planned to set up a new annual prize for pupils in the name of his parents, Campbell and Pat.
Sir Tom, who founded the Sports Division retail chain, received a painting and two framed photos of the school from the children.
Along with his wife Marion, Sir Tom established The Hunter Foundation in 1998, which has donated millions to educational and entrepreneurial projects.
"I was born locally in 1961. I'm a product of the 'toon schuil' and I have nothing but happy memories of here. However, the opening of this refurbished building is not about the past, but the future," he said.
"Inspirational teachers and early-years intervention are key in education, and these two things come together here and now in this fine school.
"When I came in headteacher Mary Smith told me I had a school library book still overdue. She said I owed her £20,000."
Poet Rab Wilson, also a former pupil, read his poem The Auld Toon Schuil in front of guests including MP Sandra Osborne, MSPs Adam Ingram and Graeme Pearson, remembering childhood days in the playground.
"Tam and I grew up together and we've been great friends all our days, so it was braw to share this magical event with him," he said.
The 198-pupil primary school now has a new gym and dining hall and has been refurbished internally. There is also a single-storey nursery for 65 children.
Local counsellor Douglas Reid said: "What we wanted was a genuine flagship building that would be the first landmark for people entering East Ayrshire from the south, and we have clearly achieved this.
"This building symbolises not only the pride that New Cumnock has in itself but also how much we as a community value education and the future of this area."