The arrest of the boy was made without further violence in the Helsinki suburb of Siltamaki, 4 km (2.5 miles) south of the Viertola school in Vantaa district, police said.
Education Minister Anna-Maja Henriksson broke into tears when speaking to reporters hours after the attack in a country where gun violence among youths is rare.
“One 12-year-old child will never again return home from school,” she said.
The suspect and the three victims were all sixth-graders, the police said in a statement.
“The injuries of both victims who were taken to the hospital are very serious,” said Criminal Commissioner Marko Sarkka.
A national day of mourning will be observed on Wednesday, with government buildings flying the flag at half-mast, the interior ministry said.