Shots were heard near UC San Diego off-campus apartments overnight.

A male graduate student has been arrested for possession of a firearm and discharging the firearm with negligence, according to UC San Diego police.

The complex at 3935 Miramar Street just south of Thornton Hospital was evacuated after the initial call came in just before 2 a.m. Wednesday. The location is west of Regents Road and north of La Jolla Village Drive.

San Diego Police were called to investigate a disturbance inside one of the units with gun shots heard.

A man, identified by officials as a graduate student, allegedly called police to report that he accidentally fired a gun.

Officers attempted to get inside the apartment but wanted to be cautious given the location. They decided to move students from nearby units.

Officers knocked on the door of UCSD graduate student Ning Ma and advised him to leave.

"I can't imagine a shooting happening around the students," Ma said. "That's so terrible."

Students were moved to nearby campus cafe. Several told NBC 7 this is finals week. Many students we spoke with said they were still awake studying or working on projects when they heard the commotion.

One woman said she heard a loud bang and then heard officers outside her building say "shots fired."

Others heard officers says "come out with your hands up."

Just before 5 a.m., San Diego Police Officers escorted a man in handcuffs to a patrol car. He was videotaped being held by officers but officials say he was later released and not charged in the crime.

SWAT officers set up a perimeter at approximately 5:30 a.m. waiting for at least one person still inside the apartment, officials said.

In less than an hour, officers had detained another man and a woman. The woman was released without charges.

Guns are not permitted in off-campus housing, according to UC San Diego Communications.

Check back for updates on this developing story.