Just after lunchtime, the pair, both wearing masks, entered a classroom at the Rudbeckianska gymnasiet in Västerås, the newspaper Aftonbladet reported.
But having threatened the students and made off with their haul, they abandoned at least some of them after teachers gave chase, the newspaper added.
Police did not confirm the details of the robbery, but said in a statement that they had been called out after “multiple perpetrators” forced people to hand over “electronics” from the school.
They asked any witnesses to come forward.
A pupil at the school told Aftonbladet that there had been a “pretty large police operation” at the school.
“It was maybe two people,” the pupil added. “The teachers chased after them, and then they threw them (the computers) into the bushes.”
School principal Henrik Pettersson told local radio P4 Västmanland, that while no one had been hurt, the robbers had managed to get the computers from the entire class.
“I have never seen anything like this,” he added.
The TT news agency reported that around 30 students had been in the classroom at the time.