Triple cop killer was ex US Marine

One of the officers killed in Baton Rogue Montrell Jackson, pictured with his son Mason

A masked former US Marine murdered three Louisiana police officers in an apparent petrol station ambush, less than two weeks after a black man was shot dead in a confrontation that sparked nightly protests that reverberated throughout America.

Three other officers were wounded in the attack in Baton Rouge, one critically. Police said the gunman was killed at the scene.

The shooting, less than a mile from police headquarters, added to the tensions across the country between the black community and police.

Just days earlier, one of the murdered officers posted an emotional Facebook message about the challenges of police work in the current environment.

US president Barack Obama urged people to tamp down inflammatory words and actions. "We don't need careless accusations thrown around to score political points or to advance an agenda. We need to temper our words and open our hearts ... all of us," he said.

The gunman was identified as Gavin Long of Kansas City, who was 29 on Sunday.

Long, who was black, served in the marines from 2005 to 2010, reaching the rank of sergeant. He deployed to Iraq from June 2008 to January 2009, according to military records.

Although he was believed to be the only person who fired at officers, authorities said they were unsure if he had some kind of help. "We are not ready to say he acted alone," state police spokesman Major Doug Cain said.

Two "persons of interest" were detained for questioning in the nearby town of Addis but were later released without charge.

Major Cain said authorities planned to continue investigating whether the gunman had any assistance "indirectly, directly here or at home".

While in the military, Long was awarded several medals, including one for good conduct, and received an honourable discharge. His occupational expertise was listed as "data network specialist".

The University of Alabama said that Long attended classes for one semester in the spring of 2012. A school spokesman said university police had no interaction with him.

In Kansas City, police, some with guns drawn, converged on a house listed as Long's.

It is the fourth high-profile deadly encounter in the United States involving police over the past two weeks. In all, the violence has cost the lives of eight officers, including those in Baton Rouge, and two civilians and sparked a national debate over race and policing.

Authorities initially believed that additional assailants might be at large, but hours later said there were no other active shooters. They did not discuss the gunman's motive or any relationship to the wider police conflicts.

The shooting began at a petrol station on Airline Highway. According to radio traffic, Baton Rouge police answered a report of a man with an assault rifle and were met by gunfire. For several long minutes, they did not know where it was coming from.

"There simply is no place for more violence," Louisians governor John Bel Edwards said. "It doesn't further the conversation. It doesn't address any injustice perceived or real. It is just an injustice in and of itself."

From his window, Joshua Godwin said he saw the suspect, who was dressed in black with a ski mask, combat boots and extra bullets. He appeared to be running "from an altercation".

Two of the murdered officers were from the Baton Rouge Police Department - 32-year-old Montrell Jackson, who had been on the force for a decade, and Matthew Gerald, 41, who had been there for less than a year.

The third victim was Brad Garafola, 45, who had been with the East Baton Rouge Sheriff's Office for 24 years.

Mr Jackson, who was black, posted his message on Facebook on July 8, just three days after the death of 37-year-old Alton Sterling, a black man killed by white Baton Rouge officers after a scuffle at a convenience store.

In the message, Mr Jackson said he was physically and emotionally tired and complained that while in uniform, he received nasty looks. When out of uniform, he said some people considered him a threat.

Police-community relations in Baton Rouge have been especially tense since Mr Sterling's death. The killing was captured on mobile phone video.

It was followed a day later by the shooting death of another black man in Minnesota, whose girlfriend live-streamed the aftermath of his death on Facebook.

The next day, a black gunman in Dallas, Texas, opened fire on police at a protest about the police shootings, killing five officers.

Thousands of people protested over Mr Sterling's death and Baton Rouge police arrested more than 200 demonstrators.

Mr Sterling's nephew Terrance Carter condemned the killing of the three Baton Rouge officers and said the family just wanted peace.