LOS ANGELES — The kindly professor whom the gunman blamed for his ruin had, in truth, quietly seen to his academic success.

As a shy graduate student struggling to secure his Ph.D., Mainak Sarkar had bristled at the doubts expressed by professors at UCLA’s engineering department. His dissertation, they told him, simply was not good enough.

Sarkar’s mentor had his own doubts, but after Sarkar submitted a new document professor William Klug asked his colleagues to wave his student through to graduation.

“We could easily have said, ‘It’s not enough, you need to do more,'” said professor Jeff Eldredge, Klug’s colleague and close friend. “We just said, ‘Ugh, let’s get him out of here.'”

That was 2013. This week, Sarkar returned.

After killing his estranged wife in a Minneapolis suburb, Sarkar packed two guns, drove from Minnesota to Los Angeles, parked in his old neighborhood, took a bus to campus and shot Klug in the professor’s office Wednesday before taking his own life.

Though Sarkar seemed to have genuine affection for his mentor while in school, more recently an animosity grew. In March, Sarkar posted online that Klug had “made me really sick” after stealing computer code from him. Colleagues said only a deranged person could conclude someone of Klug’s character would defraud a student.

“That’s what’s so frustrating about this. He turned into a completely different person in these last few days or weeks or whatever,” Eldredge said.

Sarkar’s descent may go back further than that. He held his last known job in 2014 — the same year he separated from his wife, Ashley Hasti, according to Hasti’s grandmother.

Sarkar, 38, had entered mid-life with a foundation of success, a wall’s worth of academic degrees from top universities and a new wife in his chosen country.

He came to the U.S. on a student visa in 2001 after earning a degree in aerospace engineering from the Indian Institute of Technology at Kharagpur.

In India, former classmates and teachers described a solid student who gave no indication of aggression.

He attended Stanford University from fall 2003 until spring 2005, when he received a master’s degree in aeronautical and astronautical engineering.

A year later, he moved south to the University of California, Los Angeles and began working under Klug.

Even before his death, Klug had been hailed as a caring father and gifted educator who inspired his students. Hundreds gathered to honor him at on-campus vigils.

Klug’s outgoing personality contrasted with Sarkar’s introversion.

“He was a little bit of a loner,” said Ajit Mal, an engineering professor who taught Sarkar in one of his earliest classes at UCLA.

As Klug’s career and family blossomed in his native Southern California, Sarkar struggled to finish his studies.

While at UCLA, Sarkar was “a nice guy going through the same anxieties and struggles as anyone else,” recalled Eldredge, the mechanical and aerospace engineering professor who helped review and later approved Sarkar’s dissertation.

Eldredge called Klug an exceptional person and teacher who had a gentle way giving feedback to students. Even so, Sarkar “didn’t take criticism well” when he submitted a dissertation that advisers returned, requesting significant revisions.

“He was rather combative in his responses,” Eldredge said. “He’d say, ‘I don’t know how to answer that’ or ‘I don’t know what that means.’ He was just very stubborn.”

The deaths this week left behind devastated families, a shaken university community, and many unanswered questions.

Chief among them is what led him to violence.

“Apparently he’s harbored those feelings (against Klug) over the past three years since his graduation but we’ve not been able to determine any trigger event that would have led to this or his murder of his wife,” Los Angeles police Capt. William Hayes said.

Sarkar also left behind a “kill list” that included the name of another professor who was not on campus when Sarkar arrived. Investigators haven’t said why he apparently held a grudge against that instructor.

“We’re trying to look at a trigger event but we haven’t been able to find any,” he said.