The man who fatally shot a campus police officer at Virginia Tech on Thursday before killing himself was a student at a nearby university who had stolen a vehicle at gunpoint the day before, officials said.

Virginia State Police on Friday identified the gunman as 22-year-old Ross Truett Ashley, a part-time student at Radford University in Radford, Virginia.

Ashley entered a real estate office in Radford on Wednesday and demanded the keys to an employee's white 2011 Mercedes Benz sport utility vehicle at gunpoint.

He drove off in the vehicle and later dumped it on the campus of Virginia Tech some time before his deadly confrontation with 39-year-old Deriek Crouse, an officer with the Virginia Tech campus police.

The state police said they had not been able to establish any prior contact or connection between Ashley and Crouse and did not know why he walked up to the officer and shot him before turning the gun on himself in a nearby parking lot.

Ballistics testing confirmed the same weapon was used in both shootings, police said.

The incident prompted a lockdown of the campus on Thursday and evoked memories of an April 2007 rampage by a mentally deranged student who killed 32 people and wounded 25 before committing suicide on the campus about 250 miles (400 km) southwest of Washington. That was one of the worst shooting incidents in U.S. history.

Shortly after noon (5 p.m. British time) Thursday, Crouse had a vehicle stopped in a campus parking lot when he was approached by a man and fatally shot while still in his car, police said. The man then fled.

About 30 minutes later, a sheriff's deputy saw a man acting suspiciously in a parking lot about a half a mile from the first shooting. After briefly losing sight of the man, the deputy found him dead on the ground with a handgun nearby, police said.

Police later recovered a discarded backpack on campus with clothing inside that was similar to that worn by the man seen in video taken by Crouse's patrol car.

OFFICER WAS FOUR-YEAR VETERAN OF FORCE

The man apparently changed clothes on the way to the second parking lot, Virginia State Police spokeswoman Corinne Geller said at a media briefing at Virginia Tech. Police are investigating writing found on a wall near the backpack, she said.

Officials did not lift the lockdown on campus until later on Thursday afternoon because they could not immediately identify the man as the shooter and were still investigating tips from the public, Geller said. The body did not have identification on it, but police found an ID in the backpack.

A Virginia Tech student was driving the car that Crouse had stopped, Geller said. The student has been cooperating in the investigation.

Crouse joined the Virginia Tech police department in October 2007 and is survived by his wife, five children and stepchildren, and his mother and brother.

His death is a tremendous loss to our department, Virginia Tech police chief Wendell Flinchum said at the briefing. Other departments will help patrol the campus while officers grieve, he said.

Virginia Tech implemented new alert systems, including text alerts sent to students' phones, after facing criticism for the school's response to the 2007 shootings. The systems worked exactly as expected, said Larry Hincker, Virginia Tech's associate vice president for university relations.

(Writing by James B. Kelleher; Additional reporting by Matthew Ward in Portsmouth, Virginia; Editing by Greg McCune and Peter Cooney)