A graduate student at UCLA shot and killed an engineering professor before taking his own life Wednesday in a murder-suicide that led to a lockdown and campus-wide search involving hundreds of officers, multiple law enforcement sources said.

The shootings occurred in a small office inside Boelter Hall on the Westwood campus. Students and colleagues identified the victim as William Klug, a mechanical and aerospace engineering professor and father of two young children.

The attacker was a student who was not publicly identified. Law enforcement officials investigating the suspect's background told NBC News he was an engineering graduate student who apparently had a strained relationship with Klug.

The student may have believed Klug had misused the student's computer code and may have also been upset over grades, sources told NBC News.

Their bodies were found together in an office with a handgun and a note nearby, according to Los Angeles Police Chief Charlie Beck. No one else was hurt.

"There is a note," Beck said. "I don't know if it's a suicide note. I don't know if it's a confession. I don't know what it is."

Students, who hid in classrooms and barricaded doors while police swarmed the campus, said they were in shock.

"I'm just outraged," said Renjie Li, a student who knew Klug. "I'm mad that someone would do that to a young professor who just started his career at UCLA. It’s just a shame."

Li took a computer science class from Klug and said he was one of the most approachable professors at the university.

"He was always there for us. I just really appreciate him being that type of person there when I'm in trouble doing my project or having trouble figuring out a problem," Li said. "He's definitely one of my favorite professors here at UCLA."

The department earlier received a report of a possible active shooter on the campus of 43,000 undergraduate students, setting off a SWAT search and lockdown. Campus police said they received a report of two shots fired. A campus-wide alert system notification urged students to seek shelter.

The response included hundreds of officers from UCLA, the Los Angeles Police Department and Santa Monica College, according to UCLA Police Chief James Herren. Agents from the FBI and Bureau of Alcohol, Tobacco, Firearms and Explosives also responded, and White House spokesman Josh Earnest said President Obama was briefed on the shooting aboard Air Force One.

Students, many of whom are preparing for final exams, described a large police response with officers shouting for people to find shelter.

An amazing image by my daughter Betsy Strazzante from darkened #UCLA classroom after shooting on campus. pic.twitter.com/VXmJOZehEk — Scott Strazzante (@ScottStrazzante) June 1, 2016

Causually eating pesto made by my professor in the middle of a shooting here at UCLA �� — María (@shesmariamaria) June 1, 2016

Professor has locked all the doors. She is texting me that they are all being quiet and waiting. #terrifying #ucla — Linda Colombo (@lindacolombo) June 1, 2016

Stay clear of Engineering IV. Police are on the scene. The campus remains on lockdown. https://t.co/oeYFesFnj8 — UCLA (@UCLA) June 1, 2016

Doors open outward with no locks so we had to improvise our own locking mechanism #uclashooting #engineers pic.twitter.com/GAI1OeCSzK — Pranasha Shrestha (@pranashalovesu) June 1, 2016

BruinAlert: Shooting at Engineering 4. Go to secure location and deny entry (lockdown) now!

— UCLA Bruin Alert (@UCLABruinAlert) June 1, 2016

BruinAlert: Police Activity vic Engineering Building 4. Avoid area until further notice — UCLA Bruin Alert (@UCLABruinAlert) June 1, 2016





One of my best friends is currently on lockdown. Praying for UCLA and for an end to these senseless shootings�� — Mariel Sandoval (@marielsteph) June 1, 2016

To all of my UCLA friends, please be safe !! — Michelle (@My__shell) June 1, 2016

"At first we weren't really sure it was real," said student Landen Baldwin, who was in his apartment a few blocks from campus. "It was a very quick turnaround time between the alert about police activity and the confirmation that there was a shooting. This one was very definitive within a couple minutes that the situation was as drastic as it was."

SWAT officers continued the search into early Wednesday afternoon, when robbery-homicide division detectives took over the investigation and the campus was cleared.

Classes were canceled for the day, but UCLA vice chancellor and provost Scott Waugh said campus operations would return to normal Thursday and next week's finals would not be disrupted.

"We want to resume normal operations as quickly as possible so we will resume scheduled classes tomorrow morning," Waugh said, adding that exams and commencement would continue as planned.

"I want to say that our hearts go out to the victims," he said.

The campus, located on 19 acres at the base of the Santa Monica Mountains, has an enrollment of 43,200 undergraduate students. The majority of undergraduates are from California, but the campus population includes students from all 50 states and more than 100 countries.

A GoFundMe account has been set up to help Klug's family.

NBC4's Whitney Irick contributed to this report.