BATON ROUGE, La. -- Three Baton Rouge law enforcement officers investigating a report of a man with an assault rifle were killed Sunday, less than two weeks after a black man was fatally shot by police here in a confrontation that sparked nightly protests that reverberated nationwide.

Police said the suspect was shot and killed at the scene. Authorities initially believed that two other assailants might be at large but hours later said the dead gunman was the only person who fired at the officers.

How'ever, a state police spokesman said investigators were unsure whether he had some kind of help from others.

"We are not ready to say he acted alone," said Major Doug Cain. 

Two people were detained in the nearby town of Addis. Cain called them "persons of interest."

The shooting, which happened just before 9 a.m., comes amid spiraling tensions across the city, and the country, between the black community and police. The races of the suspect or suspects and the officers were not immediately known.

The site of the shooting was a gas station and convenience store less than a mile from police headquarters.

Police said they are using a specialized robot to check for explosives near the body of the dead suspect.

Baton Rouge Police Sgt. Don Coppola told The Associated Press earlier that the officers were rushed to a local hospital. Coppola said authorities are asking people to stay away from the area.

A spokesperson for Louisiana Governor John Bel Edwards said the governor is at the hospital where the officers were taken and would be meeting with them and their families.

Multiple police units were stationed at Our Lady of the Lake Regional Medical Center, where stricken officers were believed to be undergoing treatment at a trauma centre. A police officer with a long gun was blocking the parking lot at the emergency room.

Officers and deputies from the Baton Rouge Police Department and East Baton Rouge Sheriff's Office were involved, according to Hicks.

An Associated Press reporter on the scene saw police vehicles with lights flashing massed about a half mile from the police headquarters on Airline Highway. Police armed with long guns on the road stopped at least two vehicles driving away from the scene and checked their trunks and vehicles before allowing them to drive away.

In Washington, President Barack Obama said attacks on public servants and the rule of law "Have to stop." He added that while the motive for Sunday's attack was unknown, there is no justification for violence against law enforcement.

"These attacks are the work of cowards who speak for no one," he said in a statement. "They right no wrongs. They advance no causes."

Police-community relations in Baton Rouge have been especially tense since the killing of 37-year-old Alton Sterling, a black man killed by white officers earlier this month after a scuffle at a convenience store. The killing was captured on cellphone video and circulated widely on the internet.

It was followed a day later by the shooting death of another black man in Minnesota, whose girlfriend livestreamed the aftermath of his death on Facebook. Then on Thursday, a black gunman in Dallas opened fire on police at a protest about the police shootings, killing five officers and heightening tensions even further.

Over the weekend, thousands of people took to the streets in Baton Rouge to condemn Sterling's death, including hundreds of demonstrators who congregated outside the police station. Authorities arrested about 200 people over the three-day weekend.

Michelle Rogers, 56, said the pastor at her church had led prayers Sunday for Sterling's family and police officers, asking members of the congregation to stand up if they knew an officer.

Rogers said an officer in the congregation hastily left the church near the end of the service, and a pastor announced that "something had happened."

"But he didn't say what. Then we started getting texts about officers down," she said.

Rogers and her husband drove near the scene, but were blocked at an intersection closed down by police.

"I can't explain what brought us here," she said. "We just said a prayer in the car for the families."