A 13-year-old girl was injured after her iPhone caught fire in her pants. Getty Images

A 13-year-old student from Maine suffered first and second degree burns after the iPhone she was carrying in her pants pocket caught on fire, school officials said.

The eighth grader was in class at Kennebunk Middle School when she heard a pop and smoke began to billow from her pants, school principal Jeff Rodman told ABC affiliate WMTW-TV in Portland. Maine.

Two classmates rushed to the student's aid, while another went outside to alert school staff and bring a fire blanket and extinguisher. As classmates were helping the girl out of her pants, the iPhone fell out of a pocket.

The girl was taken to Southern Maine Medical Center in Biddeford where she was treated for burns and later released.

Fire officials are investigating the incident and praised the student for remembering to "stop, drop and roll."

Explosions and fires caused by Apple products are relatively rare, but incidents in the past have mostly been the result of the devices' lithium ion batteries overheating.

In 2011 an iPhone 4 exploded mid-flight on an Australian Airline, and before that, the European Union launched a 2009 investigation after multiple instances of iPhones and iPod Touches exploding or catching fire midflight were reported in the U.K., Holland, France and Sweden.