Naila Inayat, Shereena Qazi and John Bacon

Special for USA TODAY

LAHORE, Pakistan – Taliban gunman stormed a military-run school in Peshawar on Tuesday and massacred 141 people, nearly all children, an act of barbarism that left Pakistanis in shock as they mourned the loss of relatives and friends.

"In every street of Khyber Pukhtunkhwa, someone has lost a dear one today," said Qazi Murtaza, 24, of Peshawar, whose cousin and aunt were killed in the attack. "My aunty lost her son – his funeral is tonight – and then I have to go to my uncle's house. He lost his wife."

The attack on the Army Public School in the northwestern city near the Afghan border was one of the worst incidents of extremist violence in Pakistan since a 2007 suicide bombing in the port city of Karachi killed 150 people. Peshawar has been the target of frequent militant attacks — in September 2013 a twin suicide bomb blast in a church killed at least 85 people.

Asim Bajwa, spokesman for the Pakistani military, said 132 of those killed Tuesday were children and the other nine were staff members. An additional 121 students and three staffers were wounded at the school, which includes more than 1,000 students and staff.

Bajwa said seven gunman stormed the school wearing explosive vests. They did not take hostages but instead fired indiscriminately as they entered the school.

"Their sole purpose, it seems, was to kill those innocent kids. That's what they did," Bajwa said.

Some students said the attackers detonated a bomb when all students were gathered for an exam. The surviving students described a horrifying scene.

"They were wearing plain white shalwar kameez (pajama-like trousers with a long shirt) and had very long beards. They were speaking in Arabic with each other," said Abdul Rehman, 14. "I saw them killing the students. I escaped by hiding under the chair. My best friend was also murdered, though he pleaded for his life."

Hamza Khan, 15, said many students initially thought maintenance work was being done on the building.

"At first we thought there is some repair work going on in the backyard. But then the bullets were fired in the back door of the main hall and the terrorists entered the hall and opened fire on the students," said Khan. "I won't be able to forget the horrid images for the rest of my life. I promise to take revenge for my fellow students — I will fight these cowards and destroy them."

Army commandos moved in, exchanging fire with the gunmen while students scrambled to safety. All seven gunman died in the assault, Bajwa said. It was not clear if they were killed by commandos or blew themselves up.

Pakistan's Taliban spokesman Mohammed Umar Khorasanin said the assault was "a revenge attack" for an army offensive in North Waziristan in June that targeted militants.

"We targeted the school because the army targets our families," he said in a statement. "We want them to feel our pain."

Bajwa tweeted that "several ops" had been launched by Pakistan after the attack, including 10 airstrikes.

Prime Minister Nawaz Sharif vowed that the push to drive militants from the area would not be deterred. "The fight will continue. No one should have any doubt about it," Sharif said.

People who lost loved ones were in shock at the huge loss of life in the dusty northwestern outpost of Pakistan.

Murtaza's cousin, Syed Afaq Ahmed, 16, got up, got dressed and went to school Tuesday morning to take a biology exam. He wanted to be a doctor like his older sisters. When he didn't return, his mother, frantic with worry, kept trying to call but was sure her youngest, headstrong and lively, would survive. She called the hospital. She learned she was wrong.

"My husband passed away four years ago and now my son," said Bibi Amina. "What did he do to deserve this? He got ready for school this morning for his biology exam – but instead lost his life."

President Obama was among numerous heads of state condemning the attack.

"Our hearts and prayers go out to the victims, their families, and loved ones," Obama said in a statement. "By targeting students and teachers in this heinous attack, terrorists have once again shown their depravity. We stand with the people of Pakistan, and reiterate the commitment of the United States to support the government of Pakistan in its efforts to combat terrorism and extremism and to promote peace and stability in the region."

India's Prime Minister Narendra Modi and Rajnath Singh, India's minister of home affairs, also condemned the attack. "This dastardly & inhuman attack exposes the real face of terrorism," Singh tweeted.

"This massacre represents a savage and qualitative escalation of the attacks by the Pakistani Taliban," said Fawas Gerges, a professor at the London School of Economics' Middle East Center. "This particular attack cannot be understood except as a direct attack against the Pakistani army, attacking the sons of officers who are attending the school."

He added that the Pakistan Taliban is the most extreme faction that exists in Afghanistan and Pakistan. The radical Islamists have been fighting to regain control of Afghanistan since being ousted by U.S. forces in 2001 and have been a source of instability against the Pakistani government along the two countries' border.

Gerges compared the brutality of the Taliban to that of the Islamic State: "two sides of the same coin that celebrate extremism and killing." The Taliban group in Pakistan is "an extreme Islamist faction that wants to create a similar Islamic state. ... The Pakistani Taliban has always been closer to al-Qaeda than the Taliban in Afghanistan," which had provided al-Qaeda sanctuary.

The attack also highlighted the vulnerability of Pakistani schools, which have been targeted before, most famously in an attack two years ago on Malala Yousafzai. The Pakistani schoolgirl was shot in the head by a Taliban gunman outside her school in Swat Valley for being outspoken about girls' rights. The Taliban opposes formal education for girls.

Malala has never returned to Pakistan for security reasons but has gone on to become a Nobel Peace Prize laureate and global advocate for girls' education.

On Tuesday she condemned the killings. "I am heartbroken by this senseless and cold blooded act of terror in Peshawar that is unfolding before us," she said in a statement. "I, along with millions of others around the world, mourn these children, my brothers and sisters, but we will never be defeated."

In Peshawar, residents mourned their losses while feeling on edge. "I can't believe my cousin passed away," said Murtaza. "Everyone in Peshawar is terrified now."

Qazi reported from Doha, Qatar; Bacon reported from McLean, Va. Contributing: Angela Waters, Jennifer Collins, Associated Press