The gunman who murdered three police officers and wounded three others - one of them critically - in Baton Rouge, Louisiana on Sunday, had posted videos urging Black Americans to "fight back" against the police in response to reports of police brutality, it has emerged.

29-year-old ex-US Marine Gavin Long was shot dead by officers, who he apparently ambushed after they responded to calls concerning a suspicious individual seen brandishing an assault rifle. Two other "persons of interest" were taken into custody in connection with the attack.

In his last video posted on YouTube, Long - a prolific social media user who often used the pseudonym Cosmo Setepenra - called on Black Americans to follow the examples of "revolutionary movements" by "fighting back" with "bloodshed."

He insisted that no revolutions "had been successful through simply protesting. It just doesn't work."

Sunday's shooting occurred against the backdrop of nationwide protests against alleged police brutality, particularly against black Americans. Baton Rouge in recent days has seen major protests over the shooting to death of a black resident by police there.

The shooting also came after the murder of five police officers by a black extremist in Dallas, Texas, drawing fears it was a copycat attack. Though some subsequent reports suggested the Baton Rouge shooting was in fact gang-related, Long's video messages will raise suspicions his actions were indeed aimed at murdering police specifically.

Notably, like the Dallas shooter, Long is a US Army veteran - though unlike Micah Xavier Johnson, Long's military career was apparently without blemish.

He served as a Marine from August 2005 to August 2010, including a half-year stint in Iraq during which he received a number of medals and commendations. He was promoted to the rank of Sergeant before being honorably discharged in 2010.