The Prince Of Wales School in Dorchester opened in March 1995 and invited the prince back to meet the pupils and plant an anniversary tree.
Speaking at an assembly, he said: "I am thrilled to have this chance of returning 20 years after I opened this school."
Head teacher Peter Farrington said: "I think he was very impressed."
He added: "I think last time he visited he was particularly interested in the architecture of the school and I think this time he's gone away with a very clear impression of a happy and creative school that we have become."
The prince said: "I am so pleased to see the school has gone from strength to strength."
Prince Charles has paid a return visit to a Dorset school he opened, as part of its 20th anniversary celebrations.