Every pupil in a class of 30 received an A* result in their maths GCSE.
The pupils at Fitzalan High School in Cardiff achieved the highest grade available despite taking the exams six months early, assistant head teacher Jo Kemp said.
The Year 11 group had the same teacher since starting at the secondary school - Francis Elive - who Ms Kemp said was known as "the maths whisperer".
Just 14% of pupils sitting the exam achieved an A* grade in Wales.
Some of the pupils in Mr Elive's class came close to achieving full marks.
"We did a countdown so they all opened their results at the same time," Ms Kemp said, adding the grade boundaries for achieving an A* are higher than in previous years.
"There was a gasp as they saw their results and then all realised they had the same."
Ms Kemp said the pupils had been taught to believe in themselves by Mr Elive.
"He's passionate about his subject and he is quite a reserved man but he was just on pins like an expectant dad - how you would want a teacher of your children to be feeling," she said.
"We call him the maths whisperer, he instils the belief that they have practised the hardest maths that they have to ever to face so why be scared of an exam?
"It's the belief that they absolutely can do it, and the children think it's magic."