BATON ROUGE, La. -- Gavin Long was a man of mixed messages. He peddled self-published books with abstract themes about self-empowerment and spiritual enlightenment, but also posted rambling Internet videos calling for violent action in response to what he considered oppression.

In the last message sent from his Twitter account early Sunday, he wrote: "Just bc you wake up every morning doesn't mean that you're living. And just bc you shed your physical body doesn't mean that you're dead."

Nine hours later, he ambushed law enforcement officers in Baton Rouge, fatally shooting two police officers and a sheriff's deputy and injuring three others before being shot dead himself. It was his 29th birthday.

The black military veteran, whose last known address was in Kansas City, Missouri, had spent five years in the Marine Corps, serving one tour in Iraq before being honourably discharged and taking a series of college classes. Then, according to his website, he had a spiritual awakening, sold all his possessions and moved to Africa for a time.

By May 2015, back in the U.S., Long sought to legally change his name to Cosmo Ausar Setepenra in a non-binding document filed in Jackson County, Missouri, though he never followed through with an official request, county spokeswoman Brenda Hill said.

In the document, he said he belonged to the Washitaw de Dugdahmoundyah, also known as the Washitaw Nation, a black anti-government group whose members believe they are indigenous to the United States and beyond the federal government's reach, according to the Southern Poverty Law Center.

"Under common law, an adult or emancipated person has the right to change his or her name without legal formality or permission of court to any name he or she lawfully chooses," Jackson wrote in the document. He also said: "I AM restored to my own aboriginal-indigenous appellation ... without colorable law (legal) contract from GAVIN EUGENE LONG to Cosmo Ausar Setepenra in accord with the laws, customs, religious practices, traditions, distinct identities, characteristics and divine principles and language(s) of my Ancestors ..."

In a video posted July 10, Long, as Setepenra, said he was speaking from Dallas after another black man had killed five police officers there. He said he had already decided to travel to the city before the shooting, and guessed that "the spiritual was just telling me it was the right place to come."

Long also discussed protests in Baton Rouge, which broke out after police fatally shot a black man in a confrontation in a convenience store parking lot July 5. He urged viewers to question their "mindsets" and fight back, insisting that protests alone don't work.

"You see, that's what separates me from the 7 billion. And that's why I'm so powerful because I stand on my rights," he said.

He claimed no affiliations. In one video, Long declared: "Oh, and this is very important, I just wanted to let you all know -- because if anything happens with me . I just wanted to let you all know: don't affiliate me with nothing . yeah, I was also a Nation of Islam member, I'm not affiliated with it . They try to put you with ISIS or some other terrorist group . I'm affiliated with the spirit of Justice, nothing else."

In the months leading up his fatal encounter with police, Long had used videos to promote his three-volume book series "The Cosmo Way," self-published last year. He called himself a "Freedom Strategist, Mental Game Coach, Nutritionist, Author and Spiritual Advisor" who wrote books he described as lessons about nutrition, self-awareness and empowerment.

"My advice is to question everything and everyone," he wrote in "The Laws of the Cosmos," the first volume. "Your parents, what they taught you growing up, your schooling, your society, your history, your beliefs, and everything you've been taught regarding what and who you really are."

In more recent videos, Long portrayed himself as a sort of spiritual leader and revolutionary, a man willing to take action while others focused on protests.

"You've got to fight back. That's the only way a bully knows to quit," he said.

In his rambling videos and written posts, Long discussed topics ranging from what he considered the extermination of Native Americans to the United States' fight for independence. He said that it is celebrated when "Europeans" fight oppression, "but when an African fights back, he's wrong."

Military records show Long was a Marine from 2005 to 2010, attaining the rank of sergeant. He served in Iraq from June 2008 to January 2009, and records show he received several medals during his military career, including one for good conduct. He was listed as a "data network specialist."

After the Marines, Long attended the University of Alabama for just the spring 2012 semester, according to university spokesman Chris Bryant. University police had no interaction with Long during that time, Bryant said. He also was briefly enrolled at Clark Atlanta University during the 2012-13 academic year, the school said.

Missouri court records show that a Gavin Eugene Long filed a petition for divorce in February 2011. The records don't indicate why the couple divorced, but the petition indicates they had no children. Three months after the petition was filed, his ex-wife was granted restoration of her maiden name. Last month, a case against Long by the city of Kansas City over unpaid city earnings taxes was dismissed.

------

AP journalists Hillel Italie, Maria Sudekum, Kimberly Chandler, Gerald Herbert and Janet McConnaughey, and AP researcher Rhonda Shafer contributed to this story. Hollingsworth reported from Kansas City; Mohr from Brandon, Mississippi.