An Arizona girl who posted on YouTube threatening to gun down people at her school and then kill herself has been arrested, thanks to a tip from a Toronto resident and the Toronto police.

The 16-year-old is now detained at a juvenile facility and is facing one charge of computer-tampering and one count of threatening and intimidating.

The student, from Red Mountain High School in Mesa, Az., was taken into custody by the Maricopa County Sheriff’s office Wednesday after she posted the threat to a Toronto-based transgender YouTube channel. The girl stated that “I now literally have a plan of seriously hurting… killing… murdering people in my high school.”

The owner of the channel saw the post and alerted Toronto police, who then notified authorities in Arizona.

U.S. detectives acted within hours of being informed on Wednesday and visited the student’s home, said Sheriff Joe Arpaio.

The girl admitted to posting the threat after being arrested, said police.

According to officers, the teen said she planned the attack well ahead of the massacre last week in Newtown, Conn., where 20 small students and six adults were shot and killed last Friday by a gunman at Sandy Hook Elementary school.

Police said they found three handguns at the teen’s home, which were released to the girl’s father for safe-keeping.

The parents of the teen told police that their daughter had struggled with mental-health issues and had been seen by a psychiatrist. She had also recently been asking about where the guns were stored in the house.

"We were very fortunate on this occasion to prevent another possible mass tragedy," Arpaio said in a statement. "It takes more than just law enforcement though. We need the active co-operation of parents, members of the community, and friends and neighbours to effectively stop these potential disasters before they happen."

In a statement, Mesa Public Schools thanked Toronto police for their help in the investigation.