The students from Hines Middle School in Newport News, Virginia, US, were caught when a police officer at the school received a tip-off.
They were arrested and have admitted their crime, school officials say.
The 66-year-old teacher had to miss work several times to see a doctor about stomach problems she had been experiencing.
She never realised that her own students were trying to poison her, WAVY-TV reports.
The two boys were suspended and transferred to an alternative school for troubled teens. They have been charged with attempted poisoning.
Parents of students at the school were horrified by the news.
"You hear about stuff like that on television. You don't hear of 13-year-old kids taking it upon themselves to do something like that to another person," said mum Jessica Temple.
"I don't care if you don't like your teacher but seriously that's a little scary and what if they did it to student."