The shooting began near a fountain in front of the UT Tower - the site of one of the nation's deadliest shooting rampages more than four decades ago, when a gunman ascended the clock tower and fired down on dozens of people.
Within hours of Tuesday's gunfire, the school issued an all-clear notice, but the university remained closed, and the area around the library was still considered a crime scene.
"Our campus is safe," school President Bill Powers said.
Austin Police Chief Art Acevedo expected the school to be "completely open and back to normal" by Wednesday morning.
Authorities identified the gunman as 19-year-old Colton Tooley, a sophomore math major. His parents did not immediately respond to a message left by The Associated Press.
The 50,000-student university had been on lockdown while officers with bomb-sniffing dogs carried out a building-by-building manhunt.
After the gunfire, authorities searched for a possible second shooter, but they eventually concluded the gunman acted alone. Confusion about the number of suspects arose because shots were fired in multiple locations, and officers received varying descriptions from witnesses, campus police Chief Robert Dahlstrom said.
Before reaching the library, the gunman apparently walked for several blocks wearing a mask and dark clothing and carrying an automatic weapon, witnesses said.
Construction worker Ruben Cordoba said he was installing a fence on the roof of a three-story building near the library when he looked down and made eye contact with the suspect.
"I saw in his eyes he didn't care," Cordoba said.
The gunman continued down the street, firing three shots toward a campus church, then changed direction and fired three more times into the air, Cordoba said.
A garbage truck driver leaped out of his vehicle and ran away, as did a woman carrying two babies, the construction worker said.
"I'm not scared, but I was scared for the people around me," Cordoba said.
Randall Wilhite, an adjunct law professor, said he was driving to class when he saw "students start scrambling behind wastebaskets, trees and monuments," and then a young man carrying an assault rifle sprinting along the street.
"He was running right in front of me ... and he shot what I thought were three more shots ... not at me. In my direction, but not at me," Wilhite said.
The professor said the gunman had the opportunity to shoot several people, but he did not.
Police said it was unclear whether the gunman was targeting anyone with the AK-47.
Oscar Trevino, whose daughter works on campus, said she told him she was walking to work near the library when she heard two shots behind her. She started to run and fell down. She said she later heard another shot.
"She's freaking out. I'm trying to calm her down. I've just been telling her I love her and relax, everything's fine," Trevino said.
Acevedo said officers were able to track the gunman's movements with the help of students who "kept pointing in the right direction."
The police chief said he believes the gunman ran into the library as officers closed in on him, then shot himself in the head on the sixth floor.
Police did not fire any shots, Acevedo said.
Powers credited the school's crisis-management plan and social networking for quickly warning students, faculty and staff. The university's text messaging system reaches more than 43,000 people, he said.
Laura Leskoven, a graduate student from Waco, said she was in a media management class when she received a text message from the university saying there was an armed person near the library. For the next 3½ hours, Leskoven and about 30 of her classmates sat in a locked conference room trying to keep tab on events through Twitter, blogs and text messages.
"We were kind of shocked," Leskoven said. "Our professor said, 'Well, we need to get upstairs' because we were on the first floor of the building."
Student Joshua Barajas said he usually is in the library in the mornings but was delayed Tuesday when he made a rare stop for coffee.
"These little mundane decisions could save your life. If I hadn't stopped for coffee - and I never stop for coffee because it's $4 - I could have been in that building," Barajas said. "It's creepy. I don't even want to think about it."
On Aug. 1, 1966, Charles Whitman went to the 28th floor observation deck at the UT clock tower in the middle of campus and began shooting at people below. He killed 16 people and wounded nearly three dozen before police killed him about 90 minutes after the siege began.
Associated Press writers April Castro and Jim Vertuno in Austin, Ramit Plushnick-Masti in Houston, and Diana Heidgerd in Dallas contributed to this report.