The gunman who was fatally shot by police after opening fire at the Florida State University library early Thursday was identified as a school alumnus and attorney who was "in a state of crisis," police said.

Myron May, 31, had sent hundreds of students who'd been studying for final exams running for their lives and cowering behind bookshelves. Three people were shot — two outside the building and one in the lobby, police said.

Police received a call about an "armed subject" at the Strozier Library on the school's main campus in Tallahassee at 12.30 a.m. ET. Officers confronted the gunman and ordered him to drop his weapon, a .380 semiautomatic handgun, authorities said.

"The suspect did not comply with the commands and shot at the officers," Tallahassee Police spokesman Dave Northway said. "They returned fire and the suspect was killed.” Five officers fired, and police recovered a total of 30 rounds.

Police Chief Michael DeLeo described the shooting as an “isolated incident with one person acting alone.”

May graduated from Florida State before attending Texas Tech University's law school, and he was a lawyer in Texas and a prosecutor in New Mexico before returning to Florida three weeks ago, police said. DeLeo said his diary "expressed fears of being targeted" and that he was in "a state of crisis."

"He referred to government targeting," DeLeo said, adding that investigators had not determined why he chose Florida State for the attack.

One of the shooting victims was listed in critical condition early Thursday, Tallahassee Memorial Healthcare spokeswoman Stephanie Derzypolski said. Another was in stable condition. Police said a third victim had received a "grazing injury" and was treated at the scene.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"I called my mom and just told her I loved her ... My heart was going so fast"

Some shots were fired in the library while others occurred outside the building, according to police.

Chad Huling, a 21-year-old business student, told NBC News he witnessed the confrontation between the gunman and police outside the library from a second-floor window. “The gunman was stood right under us,” said Huling, who attends Tallahassee Community College. “There were about four or five cops there, with more arriving, and they all aimed their weapons at him and shouted, ‘Get down!’ about six times. But he did not do anything so they opened fire, I would say at least a dozen times. It was very loud. The whole thing was over in about 10 seconds.”

Huling added: "I was just thinking, ‘Is this for real?' I called my mom and just told her I loved her. We thought there were two shooters at that point, that’s what everyone was saying, so my heart was going so fast."

Student Blair Stokes tweeted that she had spotted "cops with big guns running around outside" the library. "I thought I was gonna die tonight," she added.

Cops leading us as a group. pic.twitter.com/oa1WtOBn9f — Blair Stokes (@blairstokes) November 20, 2014

Steven Dawson, 19, a freshman biology major told NBC News he was studying on the third floor of the library around 12:30 a.m. ET when someone started shouting about a gunman in the building. "Everyone just dropped everything and started running," Dawson said.

After fleeing down a fire escape, Dawson said he and several others made outside. About 20 seconds later he said he heard nine to 10 gunshots from about 100 feet away near Strozier's entrance. "Everyone took off running," Dawson said. "I’ve never seen more people screaming and running."

FSU Police Department Chief David Perry said the library was “packed with students studying for final exams” and estimated that there were 300 to 400 people in the building. One group of students sought refuge behind rows of bookshelves. “Everyone started running to one side of the library, then to the back,” one 20-year-old communications student who asked not to be identified told NBC News. “People were saying, ‘Gun! There’s a shooter! Go! Go! Go!’" She said her group hid among bookcases for what she said felt like 20 minutes. Once given the all-clear, the group was escorted to a campus building next door where they stayed until 4 a.m.

International affairs student Devon Ford told NBC News that he was on the second floor of the library that he and three other people barricaded a stairwell with tables and chairs after hearing that the shooter was downstairs. Police later announced that the gunman was "in custody and no longer a threat," Ford added.

Earlier, students had been warned to "seek shelter immediately, away from doors and windows" as police responded to what they described as a "dangerous situation."

In order to provide services for our students & employees, #FSU will remain open today but ALL CLASSES ARE CANCELLED. — Florida State Univ. (@floridastate) November 20, 2014

In a statement, FSU president John Thrasher confirmed that the three wounded victims were all students. He said that counseling services were being made available to staff and students trying to “make sense of what is a senseless incident" and praised police for an “extraordinary job taking quick and decisive action to prevent further tragedy.”

Thrasher added: “Our thoughts and prayers are with the families and loves ones of all those who have been affected.” The library will be reopened Friday to students, he said at later news conference.

DeLeo said five officers from two forces were involved in the shooting and have been placed on administrative leave pending an investigation into the incident. He said it was too early to confirm whether all five officers fired their weapons.

Shamar Walters, Tricia Culligan, Christopher Nelson and Cassandra Vinograd of NBC News contributed to this report.