Police in Kentucky believe they thwarted a possible mass shooting after they arrested a man outside a manufacturing company with five loaded guns, including a modified AR-15 rifle.

Matthew Smith, 37, was taken into custody Monday after the Springfield Police Department received a call about a vehicle and a suspicious person outside of LB Manufacturing in Springfield.

Smith was sitting in his pickup truck when officers arrived and "became uncooperative," Springfield Police Chief Jim Smith told NBC News. One officer saw that Smith was holding a pistol in his hand and ordered him out of the car.

The police chief said the suspect pointed the gun at the officer's chest and the officer was able to disarm Smith and get him on the ground. Officers then located a second handgun in Smith's waistband and another at his ankle.

Matthew Smith was arrested in Springfield, Kentucky, on Nov. 19, 2018. Springfield Police Department

An AR-15 was found on the front seat of Smith's truck along with a .380 rifle. The AR-15 had been altered, possibly enabling it to fire as a fully automatic, the police chief said.

During his arrest, Smith told officers he was "going to do what he needed to do" and suggested that he had been analyzing and studying the facility. The police chief said Smith knew which entrances to the building were open and which ones were closed.

Police also believe Smith may have been to the manufacturing company before, but aren't sure if he has worked there.

"Four people stepped up and prevented what we believe was a mass shooting," the police chief said, praising the two employees who called police and the two officers who responded.

Police believe Smith may have been stalking a woman who worked at LB Manufacturing, the chief said. He had asked an employee about the woman before police were called, the chief said. The woman did know Smith, but the extent of their relationship is unclear.

Smith was charged with attempted murder of a police officer, first-degree wanton endangerment of a police officer, resisting arrest and third-degree criminal trespassing.

He is currently being held at the Marion County Detention Center.