BLACKSBURG, Va. – A gunman killed a police officer in a Virginia Tech parking lot Thursday and was found dead nearby in a baffling attack that sent shudders through the campus nearly five years after it was the scene of the deadliest shooting rampage in modern U.S. history.

The shooting took place on the same day Virginia Tech officials were in Washington, fighting a government fine over their alleged mishandling of the 2007 bloodbath.

Before it became clear that the gunman in Thursday’s attack was dead, the school applied the lessons learned during the last tragedy, locking down the campus and using a high-tech alert system to warn students and faculty members to stay indoors.

The officer was killed after pulling over a driver in a traffic stop. The gunman — who was not involved in the traffic stop — walked into the parking lot and shot the officer, Sgt. Robert Carpentieri said. Police wouldn’t talk about a motive.

It appeared the gunman died about a quarter-mile away from the traffic stop, in another school parking lot, where officials said a man was found dead with a gun nearby. While police at a news conference wouldn’t confirm the second body was the gunman, Carpentieri said “you can kind of read between the lines.”

The shooting prompted a lockdown that lasted for about four hours.

“Today, tragedy again struck Virginia Tech,” said university president Charles Steger. “Our hearts are broken again.”

The officer had served on the campus police force for four years. State police were still investigating whether he had been specifically targeted.

Sudents preparing for exams were suddenly told to hunker down. Heavily armed officers walked around campus as caravans of SWAT vehicles and other police cars with emergency lights flashing patrolled nearby.

“A lot of people, especially toward the beginning, were scared,” said Jared Brumfield, a 19-year-old freshman from Culpeper, Va., who was locked in the Squires Student Center since around 1:30 p.m.

The university sent updates about every 30 minutes, regardless of whether they had any new information, school spokesman Mark Owczarski said.

“It’s crazy that someone would go and do something like that with all the stuff that happened in 2007,” said Corey Smith, a 19-year-old sophomore from Mechanicsville, Va., who was headed to a dining hall near the site of one of the shootings.

He said he stayed inside after seeing the alerts from the school. “It’s just weird to think about why someone would do something like this when the school’s had so many problems,” Smith said.

Harry White, 20, a junior physics major, said he was in line for a sandwich at a restaurant in a campus building when he received the text message alert.

White said he didn’t panic, thinking instead about a false alarm about a possible gunman that locked down the campus in August. White used an indoor walkway to go to a computer lab in an adjacent building, where he checked news reports.

“I decided to just check to see how serious it was. I saw it’s actually someone shooting someone, not something false, something that looks like a gun,” White said.