Two weeks after replacing the American flag with an Islamic State flag at a nearby school, police say, a Utah teenager set fire to pieces of paper in his backpack and walked away.

The fire was supposed to spread to an explosive device that would ignite and fire shrapnel at his Pine View High School classmates as they ate lunch.

That’s what the student intended to happen on Monday, St. George police say.

Instead, the fire fizzled out before igniting the explosives.

None of the school’s 1,100 students were harmed.

The student was arrested that night.

He was being held at a youth detention center on suspicion of possession or use of a weapon of mass destruction, a first-degree felony; threat of terrorism, a third-degree felony; graffiti, a third-degree felony; and abuse of a flag, a class B misdemeanor.

The teenager set down the backpack in the Pine View High cafeteria at 11:39 a.m. Monday, according to St. George police spokeswoman Lona Trombley.

He stayed in the cafeteria, but not near the backpack as it began to smoke, Trombley said.

Several students noticed the smoking backpack. At 11:45 a.m., someone told a teacher and the alert was passed to the principal and the school’s resource officer.

Three minutes later, when the principal and school resource officer arrived to take the backpack away, the smoke had stopped.

“He intended for that bomb to go off, but fortunately something went wrong and it didn’t,” Trombley said.

Inside the backpack, the officer found some clothes and burned paper, according to a news release from the St. George police.

During a more extensive search of the backpack, the explosive device was found. Police have declined to release specifics about the explosives.

The device “was designed, and placed in a specific location, at a specific time, for the purpose of spreading shrapnel in a manner that was intended to injure and/or kill as many people as possible,” the news release states.

Police have not released the student’s name or age.

At 11:59 a.m., the high school’s resource officer called the Pine View Middle School’s resource officer, who happens to be a member of the Washington County Regional Bomb Squad.

When the officer arrived from the middle school, just over a mile away, he confirmed that there appeared to be ”an improvised explosive device” in the backpack, police have said.

The students were evacuated from the school at 12:18 p.m.

Officers and a bomb-sniffing dog swept the school and its campus, and didn’t find any other explosives. The school was evacuated for two hours while the FBI and a bomb squad evacuated.

Police also seized evidence that was “consistent with the material” used to build the explosive device from the teenager’s home, the Associated Press reported.

The teenager attends a class at Pine View High School, but is a resident of Hurricane, and is a student at Hurricane High School, police confirmed.

Authorities also suspect the teen was involved in what appeared to be support of the Islamic State at Hurricane High School, 15 miles away from Pine View High School, on Feb. 15. The school’s U.S. flag was found on the ground, and an Islamic State flag was raised in its place. Someone had also spray-painted “ISIS is comi” on the wall of the school.

Officials at the time believed it was a prank.

The graffiti was found the day after the mass shooting where 17 were killed at Marjory Stoneman Douglas High School in Parkland, Fla.