A Bay Area Rapid Transit officer who was accidentally shot by his partner and died Tuesday was the first in the department┬┐s history to be killed in the line of duty.

A teacher's assistant walked into a basement classroom at Purdue University on Tuesday, targeted a fellow teacher's assistant and opened fire, killing his victim before going outside and surrendering to police, authorities said.

Cody Cousins, 23, was being held in the Tippecanoe County Jail without bond on suspicion of homicide in the death of Andrew Boldt, 21, Purdue Police Chief John Cox said at a news conference at the West Lafayette, Ind., campus. The shooting took place in the electrical engineering building, and both men were engineering students.

Police said a search warrant was served at the suspect's home near the campus but would not provide details. Cox said officers were still investigating a possible motive behind the shooting.

West Lafayette Police Chief Jason Dombkowski said police had had prior contact with Cousins in an alcohol-related incident, but he did not elaborate.

Cousins and Boldt were teacher's assistants for electrical engineering courses, according to the department's website. Cousins was an assistant for Introduction to Digital System Design, a course taught by professors David G. Meyer and Cordelia Brown. Boldt was an assistant for Microprocessor System Design and Interfacing, also taught by Meyer.

"Today's shooting at Purdue University is a tragedy, and our heartfelt condolences go out to the family of the victim and to everyone in the Purdue community," Indiana Gov. Mike Pence said in a statement. "I commend the professionalism of the West Lafayette Police Department in apprehending the suspect and bringing the situation to a swift conclusion. The Indiana State Police are on the scene and will continue to assist local law enforcement with the ongoing investigation."

On Tuesday night, hundreds of students and community members gathered at a candlelight vigil for Boldt despite temperatures well below freezing.

Allie Lang, a Purdue sophomore, told the Los Angeles Times that the front steps of Hovde Hall, near the Engineering Fountain where the vigil was held, was packed. The Purdue band and drum line performed a cadence, and hymns were sung.

"It was really sad but also pretty inspiring that so many people were able to come together in such a short amount of time and just be there for one another," she said.

The incident began about noon with reports of shots being fired at the electrical engineering building on the northeast side of campus, about 50 miles northwest of Indianapolis.

The university posted an alert on its website urging students, faculty and other staff members to take shelter in place.

By 1:15 p.m., the school had canceled the alert, assuring the community that the area was secure. The engineering building remained locked down, but the rest of the 40,000-student campus reopened.

Kirk Choquette, a 20-year-old sophomore, said he was walking to his class on the first floor of the engineering building when he heard gunshots.

"Initially I didn't think they were gunshots," he said. "I thought someone was just banging on the wall.... Then I heard cops yell, 'Get down.'"

Shortly after he got to his class, he said, police evacuated students from the building.

While standing outside, Choquette said, he and a friend saw someone leave the building with what appeared to be blood on his hands.

Felicia Leibering, 18, said she was sitting in her economics class in the engineering building when she and her classmates heard yelling from the hallway.

"Our teacher was like, 'What's going on up there?' and people sort of giggled," she said.

She said the professor asked students to look into the hallway, and that minutes later police officers entered the large lecture hall and told everyone to evacuate the building.

"We didn't hear any gunshots, just kind of muffled yelling outside the room," she said. "There were cops everywhere, standing there as we evacuated the building and along the road outside."

Leibering said it wasn't until she was walking to a different building, where her next class was located, that she received a text message from the university notifying students of the shooting.

"I was in shock," she said. "I started picking up the pace to get to the building I was going to."

The school has canceled classes through Wednesday and is offering counseling services.

michael.muskal@latimes.com

saba.hamedy@latimes.com