A suspect shot dead at the scene was thought to be the only gunman involved, police said. Reports earlier suggested there was more than one gunman.
President Barack Obama said nothing justified attacks on police officers.
It is not clear what the motive is, or whether there is any link to the killing by police of a black man in the city nearly two weeks ago.
The shooting of Alton Sterling and another killing of a black man in Minnesota, led to widespread protests across the US.
It also triggered a revenge attack by a black army veteran who shot dead five officers in the city of Dallas.
Law enforcement officers have converged on a house in Kansas City, Missouri, that is listed for a man named Gavin Long - the man US media named earlier as the suspect in Sunday's Baton Rouge shootings.
In a live broadcast from the White House, President Obama called upon all Americans to unite and refrain from divisive language.
"Regardless of motive, the death of these three brave officers underscores the danger that police across the country confront every single day, and we as a nation have to be loud and clear that nothing justifies violence against law enforcement," he said.
Louisiana Governor John Bel Edwards told a news conference it was an "absolutely unspeakable, heinous attack."
Mobile phone footage from Baton Rouge showed police cars arriving at a road intersection. Several shots were then heard.
Officers were responding to a report of a man carrying a rifle along a major motorway, Colonel Mike Edmonson told a news conference. He said the gunman was dressed all in black.
Witnesses reported a man firing indiscriminately.
"We believe that the person who shot and killed our officers, that he was the person that was shot and killed at the scene," Col Edmonson said.
US media outlets are naming the gunman as Gavin Long, 29, of Kansas City, Missouri.
Two of the dead were Baton Rouge police officers and one was an East Baton Rouge Parish Sheriff's Office deputy. All three were married and had family.
One of the injured was in a critical condition, while the other two were in a stable condition.
The local sheriff's department spokeswoman told WAFB TV the incident began shortly before 09:00 local time (14:00 GMT).
A witness interviewed by the station said the shooting appeared to have broken out before law enforcement officers arrived at the scene.
Witness Brady Vancel told WAFB he saw what may have been gang members shooting at each other before police arrived.
Another witness said she saw a gunman wearing a black mask and military-style clothing.
Baton Rouge Mayor Kip Holden said he had spoken to White House officials who had offered assistance. He said it was "a defining moment" for community relations.
But he also told local media the "rhetoric from some people" after the death of Alton Sterling in Baton Rouge may be connected to the shootings, without elaborating who.
"Everything's been anti-police," he said.
Sad sad times we live in....
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit