A routine traffic stop at Virginia Tech turned violent Thursday, leaving a police officer and his assailant dead and the campus on lockdown, a scenario reminiscent of the 2007 massacre that claimed 33 lives and redefined how universities respond to emergencies.

The mayhem in Blacksburg began about 12:15 p.m., when a Virginia Tech patrol officer stopped a driver at the university’s coliseum parking lot. Someone — not the person who was pulled over — walked up to the officer and shot him. The shooter then ran.

Virginia Tech police identified the slain officer as Deriek W. Crouse, 39, of Christiansburg. A member of the force since 2007, he was married with five children, according to the Associated Press. Crouse’s body was found in a sprawling parking lot near the Virginia Tech stadium.

Virginia Tech sophomore Shawn Ghuman live chatted with readers Friday about the recent shooting on his campus. Read the chat transcript now.

The gunman and a weapon were found in another parking lot nearby, law enforcement and government officials said. Authorities say they think the gunman killed himself as police closed in. They would not say whether he was a student.

Deriek Crouse. (Virginia Tech)

Early Friday, Virginia State Police said ballistics tests confirmed that the officer and his assailant were shot with the same gun. A news release said the tests “officially linked the two fatal shootings.”

“Today, tragedy again struck Virginia Tech,” said Charles W. Steger, president of Virginia Tech. “I can only say that words don’t describe our feelings, and they’re most elusive at this point in time.”

As the incident unfolded and state troopers fanned across the campus with automatic weapons, thoughts across Virginia Tech immediately turned to April 2007, when the deadliest college shooting in U.S. history occurred. But as similar as the events seemed, the university’s response was far different.

Virginia Tech immediately went on lockdown, from the first alert at 12:36 p.m. to 4:30 p.m. Students and faculty huddled behind locked doors so that if a gunman was loose, he couldn’t get in campus buildings.

The episode provided the first real test of Virginia Tech’s vaunted emergency response system, created after the mass shooting by Seung Hui Cho, a disturbed English major from Fairfax County. University officials devised the system after intense criticism from victims’ families and independent investigators that they did not react quickly enough in 2007.

Thursday’s response — a barrage of text messages, e-mails, phone calls, classroom alerts and audible sirens across the 30,000-student campus — was nearly flawless, according to students, staff members and public officials.

“The plan played a very significant role in protecting all the students and the faculty and also to help facilitate a rapid and proper response by law enforcement officers,” Gov. Robert F. McDonnell (R) told reporters late Thursday.

The first report of shots fired came at 12:36, minutes after the shooting, and advised of gunshots in the school’s coliseum parking lot, in a southern section of campus devoted to athletics. It told the community: “Stay inside. Secure doors.”

Alerts then came throughout the day. The second, at 12:47 p.m., described a suspect as “white male, gray sweat pants, gray hat w/neon green brim, maroon hoodie and backpack” and said he was heading “on foot towards McComas,” a facility that houses health and counseling services.

A third, at 1:11 p.m., said an officer had been shot. And so it went until the last alert, at 4:31 p.m., advising, “Resume normal activities.”

“The way the university staff is handling this . . . has been very comforting,” said Matt Banfield, a senior.

He was stranded, along with hundreds of fellow Hokies, inside the Squires Student Center for much of the afternoon. The students responded with a distinct calm, he said, tapping on cellphones and gathering information from television sets, the Internet, and social networks such as Twitter and Facebook.

Jermaine Holmes, director of academic support services for student athletes, sat in his office across from the coliseum parking lot and watched officers gather around the crime scene. “The facilities folks locked down the building immediately,” he said, speaking in the first minutes of the lockdown. “We’re not allowing any students or staff to leave.”

Freshman Matthew Spencer was walking toward a campus bus stop about 12:30 p.m. when he saw police and paramedics running toward the fallen officer. Then he got the alert from the university to get indoors. A short while later, “at least 15 police and undercover cars took off” toward where the second body was found.

Much of the campus was empty Thursday, save for the Newman Library. It was a reading day in preparation for final exams. Friday’s exams were postponed because of the incident. Inside the library, students were warned to stay clear of the windows.

The circumstances of this shooting bore no real comparison to Cho’s premeditated slaughter. But that was little consolation to the Virginia Tech community, still so scarred by the 2007 shooting that locals refer to it only as “4/16” — the date of the massacre.

“We all knew people, some of us personally, that got hurt on 4/16, so this isn’t a good feeling,” said Lee Hawkins, a 2008 Tech graduate who works for the university at Torgersen Hall.

This was another surreal afternoon. Police officers wearing flak jackets and carrying automatic weapons arrived about 2 p.m. to secure the building, known as Torg. Police shepherded students onto the “bridge,” a study area that links the building with Newman Library. Officers guarded entrances and allowed students to leave if they wanted, but “at our own risk,” Hawkins said.

The shooting happened, by chance, on a day when Virginia Tech officials were in Washington to appeal a $55,000 federal penalty from the Education Department over the university’s response to the 2007 shooting.

Virginia Tech officials were criticized for taking too long to lock down the campus after that shooting. There was a two-hour delay from the discovery of Cho’s first two victims to the first e-mail alert to campus. In between, 30 others were killed in an academic building that had not been locked.

This time, alerts went out within minutes of the gunshots. “We deployed them all, and we deployed them immediately,” Mark Owczarski, a university spokesman, said at a news conference.

The campus was quiet Thursday evening. A few students walked around, but most seemed to be hunkered down in dorm rooms, studying for finals.

Kimberly Lawrence, 20, of Newport News and Chloe Toner, 19, of Great Mills, Md., were waiting for a ride and discussing the day. After the all-clear was given, there was a “mass exodus” from locked-down buildings, Lawrence said. “People tried to get food and get back to their rooms,” she said. “They wanted to talk to their family and friends and settle down.”

Peter Read, the father of one of the 2007 victims, heard of Thursday’s shooting from a colleague at his office. He said he was immediately transported to that devastating moment when he learned of the death of his daughter Mary, a member of Annandale High School’s class of 2006.

Read took Thursday afternoon off from his job as a federal contractor. “It’s hard to think about anything else,” Read said. “It’s like deja vu all over again.”

Since the loss of his daughter, Read, 49, has been an outspoken proponent of gun-control laws and helped push for new safety measures for the campus where Mary, 19, an aspiring teacher, was killed.

By coincidence, he had spent Wednesday with other relatives in Washington, testifying before an administrative judge in the school’s appeal of the federal fine.

“Tech keeps saying they learned their lessons. . . . I really hope the leadership is doing the right things to protect the community, students, faculty and staff and the people of Blacksburg,” Read said. “They seem to be so far.”

Staff writers Mark Berman, Emma Brown, Michael Alison Chandler, Annie Gowen, Tom Jackman, Jenna Johnson, Justin Jouvenal, Anita Kumar, Susan Svrluga and Clarence Williams contributed to this report. Jouvenal reported from Blacksburg.