The attack came after Mainak Sarkar, 38, had composed a "kill list" with the names of the woman and two UCLA professors, police Chief Charlie Beck said.
Detectives believe Sarkar also intended to kill the second professor but couldn't find him Wednesday on the bustling campus, Beck said.
Authorities pieced together the case as most classes resumed a day after thousands of students and staff members were locked down on the sprawling campus. Its normally tranquil paths and hallways were swarmed by a small army of officers clad in body armor and wielding high-powered rifles.
Students who could flee did, and those who couldn't leave locked or barricaded classroom doors and huddled in nervous silence.
The investigation unfolded rapidly after Sarkar left a note in the office where he killed professor Bill Klug. It mentioned the second professor on the "kill list" and asked anyone who read it to check on Sarkar's cat in St. Paul, Minnesota.
When authorities went to Sarkar's apartment, they found the list of planned targets. Authorities checked the residence of the woman in a nearby town and found her body.
Authorities have not publicly identified the woman or the unharmed professor, who also belonged to UCLA's engineering faculty.
Sarkar had disparaged Klug online and the professor knew of his contempt, but police have not uncovered any death threats, Beck said. The writings contained "some harsh language, but certainly nothing that would be considered homicidal," he said.
A blog post written in March by someone identifying himself as Sarkar asserted that Klug "cleverly stole all my code and gave it (to) another student" and "made me really sick."
The blog continues: "Your enemy is your enemy. But your friend can do a lot more harm. Be careful about whom you trust. Stay away from this sick guy."
Beck said it was Sarkar who was mentally unstable. The chief cited conversations in which UCLA officials told investigators the former PhD student's claims of stolen code are "a making of his own imagination."
Sarkar and Klug were once close. In his 2013 dissertation about using engineering to understand the human heart, the student thanked the professor "for all his help and support. Thank you for being my mentor."
Authorities believe Sarkar drove to Los Angeles from Minnesota in the past few days with two handguns he legally bought in Minnesota and with ammunition. Police working to find that car sought the public's help, saying it was a 2003 Nissan Sentra with the license plate of 720KTW.
With the guns and ammunition Sarkar carried, "he could have caused many more fatalities than the one," Beck said.
At Sarkar's apartment building in St. Paul, the only people who would open their doors Thursday said they didn't know their neighbor and that police had been there Wednesday night.
Colleagues and friends described Klug, 39, as a kind, devoted family man and teacher who coached youth baseball in his adopted hometown of El Segundo and didn't appear to have conflicts with anyone. He is survived by his wife and two children.
"Bill was an absolutely wonderful man, just the nicest guy you would ever want to meet," said Alan Garfinkel, a biology and physiology professor who worked with Klug to build a computer model of a "virtual heart" that researchers could use to test drugs without harming anyone.
Fellow mechanical and aerospace engineering professor Jeff Eldredge met Klug 17 years ago when they were doctoral students at Caltech, and they joined the UCLA faculty on the same day.
"I had looked forward to us growing into old grouchy professors together," Eldredge said.
AP writers Christopher Weber, Justin Pritchard and John Antczak in Los Angeles, and Robin McDowell in St. Paul, Minnesota, contributed to this report.