(CNN) Authorities say they are trying to figure out why a 14-year-old boy went to his former high school Friday morning and began shooting a semiautomatic rifle shortly before classes were scheduled to begin.

A 15-year-old male student who was struck in the shoulder by gunfire was in surgery Friday afternoon but expected to recover fully, officials said.

The shooting happened on the campus of Highland High School in Palmdale, California, around 7 a.m. PT, even as some students still were arriving at school.

The former student, who transferred in recent months, took out an SKS-style carbine and fired about 10 shots, video of the incident appears to show, according to Los Angeles County Sheriff Jim McDonnell.

The gun was found later at an open field west of the school, the sheriff's office said.

It is unclear what the suspect was aiming for, the sheriff said, adding that it is early in the investigation.

The suspect called his father after the shooting, telling his dad he fired the gun in the air. The father called a family friend who is a deputy and that person, who was off-duty, went to the grocery store near the shooting scene and detained the suspect.

The father also said the boy's mother had called him earlier to say he ran away from the house.

The sheriff said the boy is accused of attempted murder.

People ran after they heard gunshots

Witnesses who were outside the school described hearing a gunshot or gunshots, and seeing students running from the building.

The first of more than 100 calls to 911 came at 7:03 a.m., McDonnell said. Police arrived three minutes later.

The shift of the school resource deputy assigned to the school doesn't begin until 8 a.m. and the officer was on the way to work when the shooting happened, the sheriff said.

There are several videos from the scene, including one from a surveillance camera that recorded the incident.

The suspect was apprehended near a Vons grocery store about a mile from the school, a Los Angeles County fire official said.

Investigators were trying to determine what led up to the shooting and whether the boys knew each other.

"I wish I could tell you what his motivation was or what he was looking to do," McDonnell said.

The Bureau of Alcohol, Tobacco, Firearms and Explosives is looking into the history of the rifle and who owned the gun.

School went on lockdown

After a lockdown of more than two hours, the school started releasing students to parents and guardians, Principal Chris Grado said on Twitter

The shooting happened during "period zero," a time of extra classes before the school day's normal 7:30 a.m. start.

Ricky Munoz, 23, told CNN he had just dropped his two younger brothers and a friend off at Highland just after 7 a.m.

"About a minute later, I get a call from them saying there were gunshots" and they asked to be picked up, Munoz said.

One of the brothers, 16, told Munoz he heard one gunshot, and that students were running.

Students barricaded themselves in classroom, mom says

Nadine Luke told CNN her 18-year-old daughter called her, screaming, after she heard shots in the school. The teen was in her Reserve Officers' Training Corps class, and said students were putting sofas and desks in front of the classroom door and windows to barricade themselves inside, Luke said.

A parent, Nelson Melendez, says he took this picture near Highland High School on Friday morning. He said he was going to drop his kids off for school, but police told him to leave the area.

Lydia Gilbert, a junior at Highland, said her mother was dropping her off when a student ran up and warned her there was a shooting.

Lydia said she then heard two gunshots before she and her mom drove away.

"I was supposed to be going to school earlier than I was, but was late," she said. A shooting at the school, she said, has "actually been one of my biggest fears."

Highland High student Katharina Smith, 16, said she was driving to the school when she saw "a ton of police racing toward school."

"There were some kids running from the school, and security and sheriff were telling people to go home," she said.

A student's mother, Ana Salazar, told CNN affiliates KCAL and KCBS that her son texted her to say a shooting had happened.

"I thought he was joking, and I'm like, 'Don't mess around, that's not funny,'" Salazar said. "And he's like, 'No mom, for reals, I locked myself up. I heard it at the other side of the school. There was one shot. And I'm locked up in one of the buildings now.'"

Nearby elementary schools placed on lockdown, too

At least three nearby schools -- David G. Millen Intermediate, Cottonwood Elementary and Ocotillo Elementary -- were on lockdown, employees there said.

Highland High School will have classes on Monday, said Brett Neal, assistant superintendent of the Antelope Valley Union High School District. Extra counselors will be at all schools to assist students and staff.

Palmdale, a city of about 150,000 people, is in Los Angeles County, about 40 miles north of downtown Los Angeles.

Previous school shootings

In March, a teacher accidentally discharged a gun during a public safety class at Seaside High School in Seaside, California, injuring a student.

A 15-year-old boy was shot in the head and a 15-year-old girl shot in the wrist at Sal Castro Middle School in Los Angeles on February 1, officials said. Two other students were grazed by bullets. A 12-year-old girl was booked for negligent discharge of a firearm in that shooting, which was considered "unintentional," Los Angeles police said.