RIO DE JANEIRO—At least 377 barrels of oil spilled into Rio de Janeiro’s Guanabara Bay and a nearby river over the weekend after an attempted robbery on a pipeline, Petroleo Brasileiro SA’s Transpetro unit said, highlighting the dangers of Brazil’s thriving trade in stolen oil.

“It was a leak of significant proportions, with an impact on the mangroves,” said Maurício Muniz, an analyst at the Instituto Chico Mendes, which is associated with Brazil’s environment ministry.

Transpetro said in a statement the oil had spilled into the Estrela River, which feeds the Guanabara Bay. The company alerted authorities and activated its emergency clean-up teams immediately, and by Monday morning, almost 75% of the oil had been cleaned up, the company said.

Transpetro and Petrobras, as Petroleo Brasileiro is commonly known, have become frequent targets of theft in recent years as gangs steal millions of dollars a year of oil and derivatives and resell it on the black market.

The racket is part of a larger crime wave in Brazil, provoked by the nation’s worst recession on record.

In a statement, Transpetro said that oil visible from a helicopter flyover was limited to the banks and mouth of the Estrela River.