Tony Blair was booed and faced chants of "out, out, out" by pupils at the school at which he made a statement about his future.
Children held up banners while chanting and jeering at Mr Blair
The prime minister spoke at Quintin Kynaston specialist technology college in Marlborough Hill, north-west London.
But students at the college used their afternoon off lessons to join anti-war demonstrators at the school gates.
The college is one of the first to join the PM's trust school initiative, which are free from local authority control.
Mr Blair used his visit to the school to announce that he would stand down as prime minister within the next 12 months, but did not set a precise date.
'Time to go'
A small group of teachers cheered and applauded Mr Blair as his cavalcade approached the school gates but they were drowned out by about 60 protesters who gathered in the street outside the school.
They held placards with the words "time to go" and a 4ft model of a dog biscuit which they were offering as a "reward" to "Tony the Poodle" for his obedience to US President George Bush.
Tony Blair used the visit to announce he would stand down within a year
One 13-year-old girl said: "They [the protesters] are not exploiting us.
"We understand some stupid people in politics are trying to kill the Lebanese and Iraqis and everybody else."
And another pupil from the school, added: "We are against that and Tony Blair should go."
National coordinator of the International Socialist Resistance, Sarah Sachs-Eldridge, was leading the chants.
She said many young people were outraged by Mr Blair's decision to invade Iraq as well as some of his domestic policies.
"We just came down because we heard that Blair was going to be here," she said.
"We all know that there is anger among school students, we meet school students at every protest we do. They think Blair is more than a waste of space."
Mr Blair did not react to the protest and has not commented on it.