Videos posted to the internet by ex-marine Gavin Long said he was not affiliated with any particular group, but that he is “affiliated with justice”.
Dressed in black, Long killed three officers and wounded three others in the attack less than a mile from police headquarters on Sunday morning.
The shooting was the latest incident in a tense stand-off between police and members of the black community in the US.
Police shot dead a black man in Baton Rouge two weeks ago, raising tensions in the area. That, followed by a second death in Minnesota, sparked protests and a revenge killing of five police officers in Dallas.
In a video posted on 10 July, a man believed to be Long said he was speaking from Dallas after the fatal attack during a march over the deaths of black men at the hands of law enforcement. The man also discusses the protests in Baton Rouge and what he perceived as oppression.
He says: “You’ve got to fight back. That’s the only way a bully knows to quit.”
Long, from Kansas City, Missouri, turned 29 on Sunday, the same day he opened fire. The former marine – who sought to legally change his name to Cosmo Setepenra, a name he used in his online postings – was killed at the scene.
The shooting began at a petrol station on Airline Highway. Baton Rouge police are believed to have responded to a report of a man with an assault rifle and were met by gunfire.
A marine from 2005- 2010, Long rose to the rank of sergeant and served in Iraq, earning several medals, including one for good conduct, and received an honourable discharge. His occupational expertise was listed as “data network specialist”.
Meanwhile, the University of Alabama said that Long attended classes for one term in the spring of 2012. A school spokesman said university police had no interaction with him.
Colonel Mike Edmonson said: “His movements, his direction, his attention was on police officers.”
The dead officers were named as Montrell Jackson, 32, and Matthew Gerald, 41, of the Baton Rouge police department, and Sheriff’s Deputy Brad Garafola, 45. All three men had families.
Officer Jackson had written a Facebook post expressing how difficult it was for him to be both a black man and a police officer.
He wrote: “I’m tired physically and emotionally. Disappointed in some family, friends, and officers for some reckless comments but hey what’s in your heart is in your heart.”
He spoke of the dichotomy he faced when working as a police officer.
He said: “In uniform I get nasty hateful looks and out of uniform some consider me a threat.”
Jackson added: “Please don’t let hate infect your heart. This city MUST and WILL get better.
“I’m working in these streets so any protesters, officers, friends, family or whoever, if you see me and need a hug or want to say a prayer, I got you.”
The post, which has since been removed from Jackson’s page, ended with two emojis: a police officer and peace sign.
President Barack Obama urged Americans to tamp down inflammatory words and actions.
US Attorney General Loretta Lynch condemned the attack “in the strongest terms possible”.
She added that “families are again mourning loved ones robbed from them by senseless violence... And all of us are again heartbroken at the news of yet another tragedy.”