The girl stopped breathing, and the school's resource officer, assistant principal and other staff worked to revive her, reports CBS News.
She was also given Narcan, which is used to reverse opioid overdoses. The girl was taken to a hospital and has recovered.
An investigation determined that the student took a suspected counterfeit oxycodone tablet containing fentanyl that she bought through a social media site, police said.
Detectives later arrested two people suspected of selling the pill to the student.
Fentanyl is a synthetic opioid 80 to 100 times more powerful than morphine, and a small amount can kill.