Mr Miliband, 41, asked the youngsters at Featherbank Primary, in Horsforth, if they knew when he was at the school and laughed along with all the staff when one after another offered a date in the 1950s.
After telling a special school assembly he was there between 1974 and 1977, the Leader of the Opposition joined in with the reciting of the school motto - “Once a Featherbanker - always a Featherbanker”.
After he was greeted by head Kathie Rhodes, head boy Daniel Richardson, eight, and head girl Holly Anderson, seven, Mr Miliband listened to a concert in his honour.
He told the children he was four years old when he arrived at what was then Featherbank Infants.
He said: “It was fantastic then. I have got fantastic memories of the school.
“It’s an even more fantastic school now.”
He congratulated the pupils and staff on three successive “outstanding” Ofsted evaluations.
Mr Miliband opened a new wing of the school, which is in the Horsforth area of Leeds and has recently expanded to become a full primary school, rather than just an infants school.
He put his handprint on a wall, joking with photographers that the school had rightly chosen red paint.
Touring the building, he laughed as one little girl told him it was a brilliant school and she wanted to come in at weekends too.
After his visit, he said: “It’s been fantastic. It’s quite an eerie feeling.”
Asked about his memories of that time, he said: “Great memories, but quite distant memories because I was between the ages of about four and seven.
“I remember my teachers, I remember the school as being a very happy place.
“It certainly seems a happy place now and a great school.
“And it hasn’t changed that much, really, so a lot of it looks very, very familiar.
“As always, I remember it being bigger than it was because I was much smaller then.”