(Reuters) - A 16-year-old boy was shot and critically wounded during an argument outside a middle school in Sandy, Utah, on Tuesday, and a 14-year-old boy was taken into custody, police said.

Sergeant Dean Carriger said the bell excusing students at Union Middle School had just rung when the shooting took place.

"At about 3 p.m., Union had just released and students were leaving the property when two juveniles got into an argument that led to the shooting," he said.

Carriger said the 14-year-old boy was a student at Union Middle School but the victim was not.

The 16-year-old victim was taken to a hospital in critical condition, where he was undergoing surgery for two gunshot wounds. Local media initially reported the victim was 12, citing authorities.

Carriger said it was not immediately clear if the suspect had brought the gun to school or acquired it before the argument.

He added it was not yet clear what led to the initial disagreement.

"There were so many students in the area, our investigators have dozens of interviews to do," he said.

The Canyons School District said on its Facebook page that the middle school was placed on lockdown at the request of police following the shooting.

"We understand that police have apprehended the subject and that students are safe," the district said. The lockdown was lifted later in the afternoon.

(Reporting by Dan Whitcomb in Los Angeles; Editing by Peter Cooney)