The pupils, along with loads of adults, stormed Edinburgh Castle to show they don't agree with war in Iraq.
But most of the students didn't have permission to take time off school to take part.
Only about 30 protesters got into the castle, before staff managed to force the door shut.
The crowds left outside chanted "Don't attack Iraq".
'We don't want war'
Most of the students were from secondary schools in and around Edinburgh itself.
Some residents said it was worrying that children were involved in the protest, but campaigners said the pupils had their own opinions and had not been talked into it.