Panicked students leapt from first-floor windows to escape Perm State University around 1,300 km (800 miles) east of Moscow, landing heavily on the ground before running to safety, media footage showed.
Students built barricades out of chairs to stop the shooter from entering their classrooms, they said.
The gunman was wounded after resisting arrest and was being treated in the hospital, the Investigative Committee law enforcement agency said in a statement.
University spokesperson Natalia Pechishcheva had earlier said the shooter had been "liquidated" but later said he was in police custody. Footage from the scene showed his prone body on the ground outside.
"There were about 60 people in the classroom. We closed the door and barricaded it with chairs," student Semyon Karyakin told Reuters.
The gunman was identified as a student at the university who obtained the hunting rifle in May, the Investigative Committee said.
Local media identified the gunman as an 18-year-old student who had earlier posted a social media photo of himself posing with a rifle, helmet and ammunition. That photo could not be independently verified.