A truck driver walked into an Amish school and sent the boys outside before holding the girls hostage and shooting them.

Three children were found dead at the scene and seven others were taken to hospitals.

The gunman, Charles Carl Roberts IV (32) then turned the gun on himself, state police commissioner Jeffrey Miller said.

Roberts walked into the West Nickel Mines Amish School, in Pennsylvania, with a shotgun and an automatic handgun and barricaded himself inside after releasing about 15 boys, a pregnant woman and three women with infants.

The girls were lined up along a blackboard and their feet were bound, Mr Miller said. A teacher called police and reported that a gunman was holding students hostage.

Roberts apparently called his wife from a mobile phone about half an hour later, saying he was "acting out in revenge for something that happened 20 years ago".

Moments later, Roberts told police he would open fire on the children if officers at the scene did not back away from the building.

Within seconds, troopers heard gunfire in the building.

The school had about 25 to 30 students, aged six to 13 years.

Two hours after the shooting, about three dozen people in traditional Amish clothing, hats and bonnets had gathered near the small school building.

The school is set in farmland just outside Nickel Mines, a tiny village about 55 miles west of Philadelphia.

Numbering about 180,000, the Amish have settlements in 25 states and Ontario with 70% of the population in Ohio, Pennsylvania and Indiana.

They practise a form of Christianity that emphasises piety, modesty and community derived from a literal reading of the Bible.

Because of their belief in separating their communities from the outside world, which they consider corrupting, they have strict regulations over societal customs. They tend to dress in simple, mostly dark, clothes, speak in a German dialect, and often shun technological innovation including electricity, television, cars, telephones and tractors.

The Amish run their own schools, but most communities educate their children only up to the eighth grade, which American students reach at about 13 years old.

US courts have exempted the Amish and other groups from requiring further education on the grounds of religious freedom.

US schools have been especially sensitive to threats after deadly shootings last week at schools in Wisconsin and Colorado.

On Friday, a school principal was gunned down in Cazenovia, Wisconsin, and a 15-year-old student was charged with murder.

Two days earlier, an adult gunman held six girls hostage in a school at Bailey, Colorado, before killing a 16-year-old girl and himself.