North Dakota officials hinted Wednesday that the Fargo man who ambushed police officers Friday ā€” critically injuring two officers and killing one ā€” was possibly planning a mass shooting in the area and that the officer who shot him was the last man standing between the gunman and "some pretty horrific acts," according to Fargo Police Chief David Zibolski.

Police and fire officials were responding to a car crash on a busy street Friday afternoon when Mohamad Barakat, 37, started firing at officers, killing St. Michael native Jake Wallin.

Barakat had 1,800 rounds, multiple guns and a hand grenade in his vehicle, North Dakota Attorney General Drew Wrigley said Wednesday at a news conference regarding the use of deadly force by Fargo officer Zachary Robinson.

"In the wake of [Barakat's] murderous, unprovoked attack, officer Robinson's use of deadly force was reasonable. It was necessary. It was justified and in all ways, it was lawful," Wrigley said. "[Barakat] engaged in a completely unprovoked assault."

Wrigley said Barakat used a .223 caliber long rifle that was capable of shooting 60 rounds. From his car in a nearby parking lot, Barakat shot the police officers at the crash scene and then shot a civilian who was involved in the crash and standing on the sidewalk.

Robinson was standing away from the other officers and shot at Barakat from about 75 feet away to disable the rifle, from which about 40 rounds had been shot, Wrigley said.

Robinson then approached Barakat, who was on the ground near his vehicle and waving a 9 mm handgun in the air, and repeatedly directed Barakat to drop his weapon. Robinson came around the back of the vehicle and "gave one last command: 'Put down the gun.' He does not, and the threat is neutralized by the officer," Wrigley said, meaning Barakat was shot.

Firefighters on the scene and a nearby ambulance were essential in preventing additional fatalities, officials said. As soon as the firing stopped, "firefighters bounced out and they were applying first aid immediately to our officers," Zibolski said, which "probably had a very significant impact on their survival."

Shortly after the shooting, authorities, including the FBI, converged on a residential area about 2 miles away and evacuated residents of an apartment building to gather what they said was related evidence. In Barakat's vehicle, officials found three long rifles, four handguns and a suitcase with weapons that Barakat reportedly rolled out of his apartment before the shooting, Wrigley said.

At this point in the investigation, it appears the firearms were legally bought and Barakat didn't have prior convictions that would have prevented him from purchasing weapons, according to Wrigley.

The FBI and state Bureau of Criminal Investigation are investigating the attack. Another news conference is scheduled for Friday to address the investigation and share more information about where Barakat might have been headed.

Wallin, 23, had joined the Fargo Police Department in April. He graduated from St. Michael-Albertville High School in 2018 and then served in the Minnesota National Guard.

Robinson, 31, was Wallin's field training officer. Fargo officers Tyler Hawes, 22, and Andrew Dotas, 28, as well as bystander Karlee Koswick, 25, of Cohasset, Mass., were also shot by Barakat. Like Wallin, Hawes had joined the department this spring. Dotas was Hawes' training officer.

Fargo Mayor Tim Mahoney on Tuesday visited the two injured officers, who he said were in good spirits. Hawes was "doing well" and improving and was scheduled to have surgery on his arm Wednesday. Dotas, who was in a lung machine and couldn't speak, was set to have surgery Tuesday on his lung "but he should do better after that," the mayor said in an interview. Koswick is in good condition, a hospital spokesman said Tuesday.

Mahoney and Zibolski praised Robinson for his quick thinking and bravery during the shooting.

"Certainly this individual had in his disposal the weaponry and the intent and the commitment to place great carnage upon our community," Zibolski said. "Had officer Robinson not succeeded ā€¦ the likelihood that other people in our community would have been harmed is very high."

At the briefing Wednesday, a reporter asked Wrigley if he thought there was the potential for a mass shooting given the use of words like "great carnage" and because there were various fairs in the region on Friday.

"I won't go any further but to say, yes, there was," Wrigley said. "I said to officer Robinson upstairs, it's absolutely true [that] he was literally the last man standing between what was coming next. And you can see what this assailant was armed for."

The governors of Minnesota and North Dakota ordered U.S. and state flags to fly at half-staff at all government buildings through sunset on Saturday, and encouraged people to do the same at their homes and businesses.

Funeral services for Wallin have been scheduled for 10:30 a.m. Saturday at Pequot Lakes (Minn.) High School. Officers from the Fargo Police Department will escort Wallin from Fargo to Pequot Lakes beginning at 5:45 a.m. with arrival estimated at about 9 a.m., according to a spokesperson for the city of Fargo.

Other law enforcement agencies, first responders and the public are encouraged to be present along the route, which includes a memorial loop around the Fargo Police headquarters, as well as sections of highway in Motley, Baxter and Pequot Lakes.

The Wallin family and Fargo police will also host a public celebration of life at 1 p.m. Wednesday, July 26, at Scheels Arena in Fargo.

The Associated Press contributed to this report.