Students streamed out of the Debsirin Nonthaburi School, on the capital's northwestern outskirts, as the wounded were loaded into ambulances and teachers hugged each other and cried.
Police said the shooter, who was 14 years old, fired at least 26 bullets, and was found with 34 additional ammunition rounds.
The gun had belonged to his grandfather, police said on Friday.
One 18-year-old student told Reuters he initially thought there were firecrackers going off or someone banging an object.
"I didn't think it was a gun at first," he said.
"There were many shots: bang bang bang. Then it went quiet. Then it started again."
Lieutenant General Trairong Phophan, a spokesman for the National Police, told Reuters the suspected shooter was among the seven people killed at the school.
In an interview with news broadcaster Channel 3, Trairong said the shooter killed three teachers and three students, with 15 people injured, including two critically.
Police identified the perpetrator as a student.
It is the second school shooting in Thailand in 2026 after a teacher died and a student was injured in the south of the country in February.
Emergency worker Kiatikhun Verapongpradith, 47, described arriving as the shooting was ongoing and his team treated students with injuries in the back, chest and arms.
They found a male teacher lying dead on an upper floor of the school, and in another room they found a female teacher with wounds in her chest and arm.
He said he was called to treat the teenage shooter after hearing a final shot.
"We rushed up and found that the perpetrator had shot himself in the right side of the head and collapsed. When we got up there, we checked his pulse, he still had one, so we started CPR.
The suspect was then taken to the hospital, he said.
In the 2025 academic year, the school had an enrolment of about 3100 students and 147 teachers, according to district authorities.
"This is terrible for something like this to happen," Prime Minister Anutin Charnvirakul told reporters.
Gun ownership and gun violence are not uncommon in Thailand, which has seen a series of deadly shootings in the past six years, with children among the victims.
Thailand's worst mass killing by a single perpetrator in its recent history took place in 2022, when a former policeman ran amok in a three-hour gun-and-knife attack in the northeast that killed 36 people including 22 children stabbed as they slept at a daycare centre.
A gunman killed five people including security guards and a vendor at a Bangkok market in July 2025 before turning the gun on himself, while a teacher died in the southern city of Hat Yai in February in 2026 when a shooter opened fire at a school where she worked.
In 2020, a soldier killed 29 people in a shooting rampage in Nakhon Ratchasima.
And in 2023, a 14-year-old used a modified handgun to kill two people and wound five others at a luxury Bangkok shopping centre.
After the 2023 shooting, Anutin, who was then serving as interior minister, ordered a raft of gun control measures, including a short-term ban on new licences, import restrictions, and banning of people under 20 years from shooting ranges.
with AP