Syracuse, NY -- A Syracuse University student, who had stockpiled ammunition and gun accessories in his downtown apartment, was stopped before carrying out threats of a mass shooting, city police revealed today.

Xiaoteng Zhan, 22, was deported back to China by federal agents March 20 as he returned to Syracuse from spring break in Mexico, Syracuse Deputy Police Chief Derek McGork said.

Zhan told a friend that the "dark side" had pushed him to buy a gun, bulletproof vest and other items, McGork said, reading from an English translation of their messages.

"I might use the gun to cause trouble," Zhan said, adding, "I have been preparing."

When his alarmed friend begged him not to shoot children or kill her, Zhan responded: "You're the only one I don't want to kill."

School safety meeting held at the Onondaga County Civic Center April 5, 2018.

The deputy chief made public at a school safety task force meeting today an odyssey that led authorities from a gun shop in Madison County to a disturbed Syracuse University student to his alarmed friends in Mexico.

The result of lots of people working together -- from a gun store owner in Nelson to a maintenance worker at Zhan's apartment complex -- averted what could have been another mass shooting, McGork said.

There's no evidence Zhan ever obtained a gun, McGork said.

It all started with a tip March 12 from The Gun Store, in Nelson, which said Zhan wanted to buy an AR-15 rifle -- the weapon of choice in many recent mass shootings.

The owner called police, noting that Zhan was not a U.S. citizen but was here legally on a student visa. Zhan had a valid hunting license -- which he picked up the day before -- which allowed him to possess a gun as a non-citizen, McGork said. Zhan had taken gun safety courses in Verona.

Zhan also asked the gun store about high capacity shotguns, McGork said.

The store owner followed Zhan into the parking lot after refusing to sell him firearms. He copied down the license plate number.

Madison County authorities were quickly able to track the car to Zhan, an SU student, who lived at 324 W. Water St., the Creekwalk Commons. Syracuse police got involved.

But Zhan was nowhere to be found, McGork said.

Police didn't have enough for a search warrant -- acting suspicious and wanting to buy a rifle wasn't enough to suggest anything criminal, McGork said.

But authorities were able to find out that Zhan had sought psychiatric care at two different facilities recently. Those records showed he described drinking, suicidal thoughts, major depression, thoughts of driving a car into a tree, feelings like he might lose control and violence toward no one in particular, McGork said.

Mental health professionals agreed: Zhan wasn't someone who should have a gun, McGork said. That allowed authorities to put him on a list that prohibited stores from selling him a gun.

But police were still concerned he could find another way. And they still hadn't caught up to him.

Further investigation revealed that Zhan had also gone to Dick's Sporting Goods at Destiny USA and asked about a specific assault rifle.

When told it couldn't be sold to him, Zhan left, McGork said.

On March 16, police were contacted by an employee of Creekwalk Commons. An alarm had gone off in Zhan's room. When no one was there, the employee used a master key to get in.

And inside, the worker found ammunition.

Fortunately, by then, authorities had discovered Zhan's whereabouts: he was still in Mexico on spring vacation.

Friends there had contacted SU on March 16 concerned about Zhan's behavior, McGork said.

Among the things Zhan had told others: "The reason I want to buy guns is not to go hunting... I might do something extreme in the future."

On March 19 -- six days after the initial tip from the gun store -- police felt they had enough for a search warrant. A judge approved it.

Inside Zhan's apartment, police found the gunsights, more ammunition of various kinds, a shotgun shoulder carrier, laser scope and light.

Still, Zhan had committed no crime, McGork said. But the evidence so far was enough to get an involuntary order to commit him in a psychiatric hospital.

SU revoked Zhan's status as a student. And because he was no longer enrolled in school, his visa was no longer valid.

So federal agents were waiting for Zhan when he flew back to Newark from Mexico, McGork said.

Zhan was immediately deported to China. Authorities contacted their Chinese counterparts to fill them in. It's not clear what Zhan's status is back home.

McGork noted that -- even with the luck of alert civilians, coordination between agencies and concerned friends -- it still took six days to get a warrant to search Zhan's apartment.

And authorities were lucky that Zhan left the country on spring vacation while they caught up to him, McGork said.

The next time, we might not be so lucky, he concluded.

Onondaga County DA William Fitzpatrick, as well as County Executive Joanie Mahoney and Syracuse Mayor Ben Walsh, put together a large group to coordinate school safety locally.

Today's meeting included doctors, academics, top law enforcement and community members.

Fitzpatrick, who chaired today's meeting, told the group he hopes they will be able to come to agreement on some recommendations by the end of the summer to help local and state authorities prepare for a school shooting.

Editor's note: A previous version of this story incorrectly stated that a gun was found during the investigation. In fact, gun accessories and ammunition were found, but no gun.