Feb. 11 (UPI) -- Police arrested an 18-year-old gunman after he allegedly took students and teachers hostage at a school in Songkhla in southern Thailand on Wednesday.

The gunman entered the Phatong Prathan Keeriwat School in Songkhla's Hat Yai district and fired shots shortly before 5 p.m. local time, and at least three people were injured, the BBC reported.

The school's principal and a female student were shot and taken to a local hospital to treat their wounds, while another student was injured while jumping off the school building.

The armed man eventually surrendered after a 2-hour standoff with local police. Law enforcement officials suggested the gunman carried out the attack due to a problem he had with a teacher.

Local police said all students, teacher and staff were safe, aside from the three who were injured during the attack.