The man who shot dead a campus police officer at Virginia Tech on Thursday before killing himself was a student at a nearby university who had stolen an SUV 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, Va.

Ashley had entered a real estate office in Radford on Wednesday and demanded the keys to an employee's white 2011 Mercedes Benz 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 W. Crouse, an officer with the Virginia Tech campus police.

The state police said they have not been able to establish any prior contact or connection between Ashley and Crouse and still do not know why the part-time student walked up to the officer and shot him before turning the gun on himself in a nearby parking lot.

The incident prompted a lockdown of the campus on Thursday and revived memories of a gunman's 2007 rampage that left 33 people dead in one of the worst shooting incidents in U.S. history.

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

Shortly after noon/1700 GMT on 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 Montgomery County sheriff's deputy saw a man acting suspiciously in a parking lot about a half a mile/0.8 km away 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.

The man apparently changed clothes on the way to the second parking lot, Virginia State Police spokeswoman Corinne Geller said at a media briefing held on Virginia Tech's campus. 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.

Officials are still trying to determine Ashley's whereabouts before the shooting, Geller said. It's likely he is connected to a vehicle that was stolen in nearby Radford, Virginia, but police haven't confirmed that, she said.

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 step-children, 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.

The incident evoked grim memories of April 2007 when a mentally deranged student killed 32 people and wounded 25 before committing suicide on campus about 250 miles/400 km southwest of Washington.

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

A candlelight vigil has been planned for Friday night near the memorial for the victims of the 2007 shooting.

A white Fiat van rammed into pedestrians outside enjoying a late afternoon stroll on Las Ramblas in Barcelona on Thursday killing at least 13 people and leaving hundreds injured. The Islamic State group claimed responsibility for the attack.