Authorities said mental health treatment was an important consideration in plea negotiations with a Dalton teacher who barricaded himself inside his classroom in February and fired a handgun.

Randal Davidson pleaded guilty Tuesday to causing damage to property, carrying a gun on the campus and disrupting school operations. He apologized in court for his role in creating panic at Dalton High School during the incident, according to the Dalton Daily Citizen.

No one was seriously hurt, but the Feb. 28 incident forced evacuations and sent panicked students running through the halls. One student suffered an ankle injury in the commotion.

Davidson, a former social studies teacher, was sentenced to two years in prison followed by eight years on probation.

RELATED: Cops: Dalton teacher who fired shot in classroom once tried to confess to murder

MORE: Teacher who fired gun in classroom out on bond, will not have contract renewed

His attorney, Richard Murray, said Davidson, 53, came to school that day intending to kill himself “in the place he felt loved,” the Daily Citizen reported.

“He did not mean to hurt those kids,” Murray told a judge during sentencing Tuesday. “But he was so absorbed in his own depression and his own mental illness that he just wasn't considering them. Yes, he is responsible for his actions, but there are mitigating factors."

A history of mental illness, severe financial pressure and the recent death of his father contributed to Davidson’s plans, Murray said.

Who Is Randal Davidson, Teacher Who Allegedly Fired Shot In Class

Davidson had previously been hospitalized three times after authorities responded to calls about worrisome behavior, The Atlanta Journal-Constitution previously reported. School officials were aware of those incidents and “were confident that Mr. Davidson was fit,” a spokesman for the district told The AJC.

RELATED: A burning car and bolt-action rifle: alleged Dalton shooter had a past

MORE: Dalton school officials knew of teacher's previous odd behavior, took steps

Investigators believe Davidson’s goal that day was likely to be killed by police, “an act sometimes described as ‘suicide by cop,’” District Attorney Bert Poston said in a statement.

Poston said he met with faculty, staff, students and parents at the high school, about 91 miles northwest of downtown Atlanta, before deciding on the terms of the plea deal. The case involved nearly 2,000 victims, all of whom were given an opportunity to have their voice heard over a series of meetings.

Ultimately, the victims felt prison time was warranted, but it was important that Dalton seek mental health treatment at his own expense, the Daily Citizen reported.

“All parties were in agreement about the final terms of the plea agreement and (the school’s principal) spoke at sentencing in support of the agreement,” Poston said.

The February incident unnerved a community already on edge in the wake of a mass shooting at a Florida high school earlier that month.

School officials were first notified before third period that day, when some students arrived for Davidson’s class and he would not let them in the room, Dalton police spokesman Bruce Frazier said.

The students told principal Steve Bartoo. When he came to the door and used his key to try to open it, Davidson forcibly closed it on him, Frazier said. Davidson warned Bartoo he had a gun. Then the principal heard a gunshot.

The bullet went through a window and outside.

“Not knowing where the shot was aimed or if more were to follow, Bartoo retreated and put the school on immediate security lockdown,” Poston said. “Once authorities were notified and first responders were in route, Bartoo ordered an evacuation of the school starting with the classrooms nearest to Davidson’s.”

After about 30 to 45 minutes, authorities got Davidson to surrender.

Under the plea deal, prosecutors agreed to drop charges of aggravated assault and possession of a weapon during the commission of a crime, the Daily Citizen reported.

Davidson can’t have contact with current Dalton High students and he won’t be allowed on any school property as conditions of his sentence.

In related news: 

The Dalton High School teacher faces a number of charges, including aggravated assault.