He said: "I guarantee ... under a future Conservative government there will be no return to the 11-plus and no return to a grammar school system. I think that's the right way of going about things."
He told parents, teachers and governors at Chalvedon school and sixth-form college in Basildon, Essex, that instead he would push for setting by ability.
"I want the Conservative party to help me campaign in setting by each subject in every school so that we do what I think is common sense, which is to stretch the brightest pupils and help those in danger of falling behind... There's a real case for more selection within schools rather than selection between schools."
He claimed that despite the promise by Tony Blair to introduce setting in 1997, only 40 per cent of classes were set by ability.
The Department for Education and Skills said 35 per cent of key stage 4 lessons were set by ability, 36 per cent in KS3 and 10 per cent in KS2. But the figures varied significantly between subjects, with setting in 80 per cent of all maths lessons and 60 per cent of science lessons.
Mr Cameron confirmed, for the first time as leader, that he would keep student fees. "I think we are going to have to keep student fees," he told a class of sixth-form students he was helping to teach politics. He said he wanted as many people as possible to go to well-funded universities, but, in order to also keep taxes down, the money would have to come from somewhere.
David Willetts, the shadow education spokesman who accompanied Mr Cameron to the school, said the "pupils' passport" was up for review. At the last election the Tories proposed that parents would be able to spend their entitlement on private education if fees were the same or less than a state-school place. It would not have allowed parents to top up the entitlement.
He renewed his demand for schools to have more say over selection. He said it was wrong for schools specialising in music to be allowed to select up to 10 per cent of pupils by aptitude in their specialism, while banning those specialising in maths from doing the same.