(CNN) Baton Rouge Police Chief Carl Dabadie Jr. said Monday that the attack that killed three law enforcement officers and wounded three others showed why militarized police tactics are needed.

In the last two weeks, police have been ambushed by skilled gunmen in Dallas and Baton Rouge and have taken multiple casualties.

On Sunday, the Baton Rouge SWAT team's training kicked in and the team performed flawlessly in responding to an ambush on officers, an emotional Dabadie said in the Louisiana city.

East Baton Rouge Parish Sheriff Sid Gautreaux said he was "convinced" that if the SWAT team had not arrived when it did, the two wounded deputies would be dead and the gunman would have escaped to attack more officers.

A SWAT team rifleman took out the gunman from more than 100 yards without a clear line of sight, Dabadie said.

"That shot our SWAT team made was a helluva shot," Dabadie said. "We've been questioned for the last (two) weeks about our militarized tactics and our militarized law enforcement. This is why. We are up against a force that is not playing by the rules. They didn't play by the rules in Dallas and they didn't play by the rules here."

"This guy was going to another location. He was not going to stop here," Dabadie told reporters. "He was going to take more lives."

Col. Michael D. Edmonson, superintendent of Louisiana State Police, said the gunman, Gavin Long, a former Marine from Kansas City, Missouri, was skilled in his handling of the assault rifle and moved skillfully to repeatedly ambush officers. Surveillance video captured the calculated attack and showed a scene that was "chilling in the sheer brutality," Edmonson said.

"There is no doubt whatsoever that these officers were targeted and assassinated," he said.

Long appears to have been in Baton Rouge several days planning his attack, and investigators are now tracking his movements before the 8:40 a.m. Sunday ambush to determine with whom he had contact and who may have known about his plans, Edmonson said.

"We want to know what brought him here, what kept him here" and why he killed police, the superintendent said.

The attack took place near a convenience store favored by officers because it was near police headquarters.

Long used a IWI Tavor SAR 5.56 rifle with a strap on it to keep the rifle in place as he engaged the officers, helping him maintain accuracy. He also was armed with a 9mm pistol and a Stag Arms M4 variant 5.56 rifle. The rifle was staged inside his Chevrolet Malibu rental car so he could get to it during the shooting, Edmonson said.

"He was extremely accurate," Edmonson said.

Details of the ambush

Edmonson and Gautreaux outlined Long's movements, step by step.

He initially spotted a Baton Rouge patrol car at a B-Quik convenience store while scouting the area in the car he had rented in Missouri. Long parked behind the building next door. He stalked the officer with his rifle poised to shoot, only to find a empty squad car, Edmonson said.

He then drove north on Airline Highway and saw another patrol officer vacuuming his car at a car wash next to the convenience store and parked behind a fitness center next door. By the time he had exited his car and neared the car wash, that officer also disappeared.

Long made his way back behind the buildings to the area near the B-Quik, which was a favorite stop for patrol officers. About this time Officers Matthew Gerald, 41, a military veteran with three tours in Iraq with a year on the force, and Montrell Jackson, 32, a 10-year-veteran, were behind the building next to the B-Quik along with sheriff's Deputy Brad Garafola, who apparently had responded to reports of a "dude with a rifle going down Airline Highway," Edmonson said.

Long used the front of the building for cover and then pivoted the corner, ready to fire, saw the two Baton Rouge officers and shot them, killing one immediately and wounding the other, Edmonson said.

Garafola who was farther behind the building, heard the shots and took cover behind a dumpster. He saw the wounded officer crawling behind the building and ran to his aid, Edmonson said,

Long stepped from around the corner in the back of the building and shot the deputy, who fell to the ground from where he returned fire, authorities said.

"My deputy went down fighting," Gautreaux said. "He returned fire to the very end. We could actually see in the video the bullets hitting the concrete around him."

Once Long killed Garafola, he saw the wounded officer move and "shot him twice," Gautreaux said.

Long shot and wounded an unidentified police officer who had pulled up in front of the building. The attacker then retreated back to the Malibu he had parked behind the fitness center several hundred yards away, using the businesses and woods for cover, Gautreaux said.

Back at the fitness center, Deputy Nicholas Tullier, 41, had just got back in his patrol car to run the tag of the Malibu when Long emerged in the parking lot, Gautreaux said.

Long opened fire on the deputy immediately, shooting as he walked toward the patrol car, Gautreaux said.

He took long shots at another arriving deputy in the front parking lot, shattering the bone running from his elbow to his shoulder, Gautreaux said.

Deputy Bruce Simmons, 51, now has a titanium rod in his arm and faces more surgery for his wounds, Gautreaux said.

It was then that Baton Rouge Police SWAT saved the day, he said. Pulling up in front of Benny's Car Wash, a rifleman saw the gunman and managed to kill him with a 100-yard-plus shot, despite buildings and other obstructions, Gautreaux said.

"I am convinced if Baton Rouge city SWAT would not have arrived at the scene we would have two more deceased deputies and this guy would have been in a position to get in his car and seek other targets," Gautreaux said.

Louisiana plans extensive investigation

Edmonson said authorities are convinced that Long was the only shooter operating during the ambush, but they plan an extensive investigation to determine whether he had any help or was affiliated or encouraged by any group.

"This is a big puzzle," he said. "Three officers are dead and one is fighting for his life, and we owe it to them to do it right and get it right. We owe that to them."

"We as a nation have to be loud and clear that nothing justifies violence against law enforcement," President Barack Obama said. "Attacks on police are an attack on all of us, and the rule of law that makes society possible."

Since the shooting death of Sterling by Baton Rouge police , the department has worried about threats against officers.

It has been an emotionally charged few days across the country because of protests stemming from Sterling's death and the shooting by police of Philando Castile in Minnesota, plus the ambush in Dallas.

Quinyetta McMillon, mother of Sterling's son, Cameron, put out a statement Sunday through her attorneys condemning the attack.

"We are disgusted by the despicable act of violence today that resulted in the shooting deaths of members of the Baton Rouge law enforcement," she said. "My hope is that one day soon we can come together and find solutions to the very important issues facing our nation, rather than continuing to hurt one another."

Police across the country are taking precautions.

The New York Police Department is doubling up all foot patrols and security posts, according to a memo obtained by CNN. Officers are also being instructed to take all meals and personal breaks in pairs. The Pittsburgh Bureau of Police is closely monitoring all calls for service and making sure backup is available under all circumstances.

In Cleveland, the police union asked Gov. John Kasich to restrict the state's open carry laws temporarily for the Republican National Convention in light of the events in Baton Rouge.

For better protection, the Boston and Sacramento, California, police departments are requiring that two officers be in every patrol unit.

Indianapolis police are ordering officers to go through training on how to recognize an ambush before it happens and what to do if they find themselves the target of one. Two officers in the Baltimore Police Department must now respond to every call.

Several departments across the country told CNN that they are taking more safety measures, but declined to describe them.

Although Baton Rouge is "hundreds of miles away from Boston, the pain and suffering caused by the loss of these officers in the line of duty is felt deeply by the men and women of the BPD," Boston Police Commissioner William Evans said Sunday. "This all too common trend we are seeing of violence against law enforcement officers who are out there each day serving and protecting neighborhoods across the country is alarming and disheartening."

Obama urged a stop to the bloodshed.

"Only we can prove, through words and through deeds, that we will not be divided," the President said Sunday. "And we're going to have to keep on doing it again and again and again. That's how this country gets united."

Photos: Tragic July in Baton Rouge Photos: Tragic July in Baton Rouge A still image taken from a bystander video of Baton Rouge police officers tackling Alton Sterling before he was fatally shot. Hide Caption 1 of 9 Photos: Tragic July in Baton Rouge Alton Sterling from Facebook. Hide Caption 2 of 9 Photos: Tragic July in Baton Rouge Sandra Sterling, Alton Sterling's aunt, visits the memorial for him at the Triple S Food Mart in Baton Rouge, Louisiana, on July 7. Hide Caption 3 of 9 Photos: Tragic July in Baton Rouge Demonstrators gather after marching on July 9 at the Louisiana Capitol in Baton Rouge to protest the shooting of Alton Sterling. Hide Caption 4 of 9 Photos: Tragic July in Baton Rouge Protestor Ieshia Evans is detained by law enforcement near the headquarters of the Baton Rouge Police Department on July 9. Hide Caption 5 of 9 Photos: Tragic July in Baton Rouge Alton Sterling's son Cameron cries as he precedes his father's casket after the funeral for his father at the F.G. Clark Activity Center in Baton Rouge on July 15. Hide Caption 6 of 9 Photos: Tragic July in Baton Rouge The casket of Alton Sterling is driven away after his funeral. Hide Caption 7 of 9 Photos: Tragic July in Baton Rouge From left, Antonio Thomas, 17; Trashone Coats, 23; and Malik Bridgewater, 20, after their arrest for stealing guns they allegedly planned to use to kill police officers. Hide Caption 8 of 9 Photos: Tragic July in Baton Rouge Baton Rouge police block Airline Highway after police officers were shot on Sunday, July 17. Hide Caption 9 of 9

Louisiana Gov. John Bel Edwards, who described the shooting as an "absolutely unspeakable heinous attack," appeared Monday on CNN, and reflected on the pain that officers' relatives and co-workers endured at the hospital.

"Emotions are raw," the governor said. "There's a lot of hurting people."

The victims

Slain officers, from left, Montrell Jackson, Brad Garafola and Matthew Gerald.

Officers Jackson , 32, and Gerald, 41, were assigned to the uniform patrol bureau.

Gerald had been serving for less than a year and had joined the force after extensive military service, with stints in both the Army and the Marines, with three tours in Iraq, Dabadie said.

"His sense of service drew him to law enforcement when he got out of the military," Dabadie said.

Dabadie said he had last spoken to Jackson, whose son turned 4 months old on Monday, a few days ago when he had gone to boost the morale of the badly demoralized department that has been heavily criticized after the Sterling killing,

Instead, Jackson ended up giving him a pep talk, Dabadie said.

Jackson had posted on Facebook on July 8 how physically and emotionally drained he had been since protests had erupted in Baton Rouge after the killing of Sterling by police.

"I swear to God I love this city, but I wonder if this city loves me. In uniform I get nasty, hateful looks and out of uniform some consider me a threat. ... These are trying times. Please don't let hate infect your heart."

Garafola, 45, worked for the East Baton Rouge Sheriff's Office for 24 years, according to Casey Rayborn Hicks, a spokesman for the sheriff's office.

He had four children, Gautreaux said.

Meanwhile 41-year-old Tullier is "fighting for his life," and 51-year-old Simmons, who has 23 years of service, face months of recovery, Gautreaux said.

The shooter

Long, a black man from Kansas City, was discharged from the Marines as a sergeant in 2010.

CNN has filed a Freedom of Information Act request with the military to obtain records about Long's service. Under Defense Department rules, health records that might include any information on Long's mental health are considered protected, even though he is dead. The records are part of the criminal investigation.

CNN has filed a similar request for the records of Micah Johnson , also formerly a military member. He killed five police officers in Dallas, and a criminal investigation is ongoing about his military record.

Long served from August 22, 2005, to August 1, 2010, according to the little information the military has released. He was a data network specialist who received the Marine Corps Good Conduct Medal, Navy Unit Commendation Medal and others. He signed up for the service in Kansas City and deployed to Iraq from June 2008 to January 2009.

The releasable record on Long doesn't indicate where he worked in Iraq.

He left a long trail of information online about his beliefs under the pseudonym Cosmo Setepenra