Minnesota police arrested on Sunday a man they say barricaded himself in a large apartment building after shooting a police officer and two other individuals and then held cops at bay for more than eight hours.

Albert Lea police identified the man who was arrested as 21-year-old Devin Matthew Weiland, according to reports. He was taken into custody when the standoff ended shortly before 11 a.m.

The officer who was shot drove himself to the hospital after being struck in the chest, police said. The 30-year-old officer was treated and released. It was unclear if he was wearing a bullet-proof vest.

UTAH MEN ARRESTED AFTER 'DISCARDED' BODY FOUND IN DESERT, POLICE SAY

The officer was called to the apartment complex to investigate reports of someone setting off fireworks or firing a gun. Police received the calls around 2:18 a.m.

“Upon arrival, a suspect ambushed an ALPD officer, shooting multiple times; at least two impacts to the squad and one impacting the officer's chest,” police said.

The other shooting victims were a 52-year-old man and a 38-year-old man. The older man was flown to a hospital in Rochester.

A reporter or KARE-TV reported that the suspect was shooting out of a third-floor window.

Officers at the scene ordered other residents of the apartment complex to shelter in place.

TEXAS POLICE FIND WOMAN'S BODY IN TRUNK AFTER CAR CHASE ENDS IN CRASH

They evacuated the building to process the crime scene after Weiland was arrested.

The evacuation displaced about 130 tenants, according to reports. United Methodist Church opened its doors to those who needed a place to stay.

Minnesota Gov. Tim Walz released a statement thanking law enforcement for protecting residents from any further harm.

CLICK HERE TO GET THE FOX NEWS APP

“We know that one Albert Lea police officer was injured today, and the first lady and I wish them a quick recovery. Thank you for your bravery and service,” he said.