It begins as a clear trickle, pure and cool, clean and drinkable, deep under the canopy of the mountain jungles that surround Rio de Janeiro.

After a serpentine mile, still narrow enough to be crossed with a leap, it enters the upper reaches of Greater Rio’s dense and jumbled sprawl, seas of brick and concrete, neighborhoods in conflicting states of decay and construction.

Over 20 miles, widening as it goes, the Rio Sarapuí fills with water from tributaries and with the untreated waste and unwanted garbage of millions who live along its path.

More than 50 rivers and streams drain into Guanabara Bay. The Rio Sarapuí provides roughly 10 percent of the fresh water that feeds the bay -- none of it filtered of the sewage and garbage from upstream.

It is rivers like the Rio Sarapuí that have turned picturesque Guanabara Bay from postcard to poison. It is rivers like the Rio Sarapuí, and the people who live alongside them, that have both nothing and everything to do with the Summer Olympics.

Guanabara Bay Rio Sarapuí Rio de Janeiro Maracanã Stadium Senador Camará Olympic Park Copacabana 5 miles Atlantic Ocean Guanabara Bay Rio Sarapuí Rio de Janeiro Maracanã Stadium Senador Camará Olympic Park Copacabana 5 miles Atlantic Ocean Guanabara Bay Rio Sarapuí Rio de Janeiro Maracanã Stadium Senador Camará Olympic Park Copacabana 5 miles Rio Sarapuí Guanabara Bay Maracanã Stadium Senador Camará Olympic Park 5 miles

A major part of Rio’s winning Olympic bid was a plan to capture and treat 80 percent of the sewage that flows into Guanabara Bay, something organizers now admit will not happen — certainly not by August, if ever. For the past couple of years, sailors in training for the Olympics have reported putrid conditions and floating debris, their stories and shocking pictures drawing worldwide attention to the tainted water. Some have unsuccessfully called for the relocation or postponement of sailing and other open-water events, such as kayaking, triathlon and marathon swimming.

But Olympic athletes and international visitors will come and go. Remaining will be roughly nine million people who live in the watershed of Guanabara Bay. About half of them are not hooked up to sanitation systems.

The Rio Sarapuí is one of many rivers that receive untreated sewage on their way to Guanabara Bay.

“People are standing on the edge of the bay, looking at the bay, and saying: ‘Oh, the bay is so dirty. The bay is so polluted,’” said Paulo Rosman, a professor of oceanography and coastal engineering at the Federal University of Rio de Janeiro. “O.K., stop. Turn 180 degrees. That’s the problem. Not the bay. The bay is just a consequence.”

RIO SARAPUÍ Jardim Silvana Bangu Jardim Gramacho Guanabara Bay Senador Camará Tubiacanga RIO SARAPUÍ Bangu Guanabara Bay

Guanabara Bay was discovered by Portuguese explorers on Jan. 1, 1502 — hence the name Rio de Janeiro, or River of January, for the settlement that grew on its shores. Pollution problems are relatively new, largely beginning with oil refineries in the 1950s. Today’s issues are mostly attributed to unchecked growth over the past couple of generations, including in the favelas, or slums. Sanitation and other infrastructure could not keep up.

Now, the task of retrofitting sewer systems, connecting all the packed houses with pipes that bring clean water and carry waste to treatment plants, is extraordinarily daunting, both logistically and financially.

Urban extent 1975 Guanabara Bay Rio de Janeiro 5 miles Urban extent 2015 Guanabara Bay Rio de Janeiro 5 miles Urban extent 1975 Guanabara Bay Rio de Janeiro 5 miles Urban extent 2015 Guanabara Bay Rio de Janeiro 5 miles Urban extent 1975 Guanabara Bay Rio de Janeiro 5 miles Urban extent 2015 Guanabara Bay Rio de Janeiro 5 miles Urban extent 1975 Guanabara Bay Rio de Janeiro 5 miles Urban extent 2015 Guanabara Bay Rio de Janeiro 5 miles Source: Landsat | Note: Satellite imagery analysis by The New York Times shows urban and barren areas in black.

The first people who encounter the Rio Sarapuí, in a violent, militia-controlled neighborhood called Senador Camará, call it “waterfall water” and fill drinking bottles with it. No one calls it the Sarapuí yet. It is little more than an ordinary canal, and within a couple of blocks, houses are dumping raw sewage and trash into it.

A couple of miles downstream, in the middle-class neighborhood of Bangu, Marcio José do Nascimento is a so-called cart man, paid by neighbors to collect construction debris and garbage left at their doors. Most is hauled behind his home, on the riverbank, and dumped into a pile at the river’s edge.

“I will not lie to you,” he said while standing shirtless on the riverbank behind a maze of homes built on top of one another. “We just throw it wherever we can find.”

Marcio José do Nascimento, the cart man.

Terezinha Parangaba, a Bangu neighbor, added: “As a child, I used to catch fish in this river, for pets, in plastic bottles.”

That changed as the neighborhood grew denser with houses and water arrived already polluted by those upstream.

“People simply got used to it,” said Andreia de Araújo Menezes, another longtime resident. “The children don’t know it as a river. They know it as a sewage trench. What arrives in the bay is produced here.”

A block from the river, Antônio da Costa tried to unclog a narrow pipe under the street with a trowel and 20 feet of thick wire. Waste from the toilets and drains of seven houses flows through this pipe to the Rio Sarapuí, and it is often clogged with sewage, trash and diapers. The backup bubbles through a broken concrete manhole cover and enters the front door of Maria das Graças’ home.

“Every month, something happens that it gets clogged, even when it doesn’t rain,” she said. “Sometimes I wake up, and there is a lot of sewage in my house. I suffer the most because it is in front of my home.”

Da Costa retrieved this day’s culprit: a four-inch plastic dog.

Locals unclogged a pipe that frequently overflows and floods their houses in Rio’s Bangu neighborhood.

As it slows and widens, the Rio Sarapuí passes thousands more homes and several factories and refineries, all of which see the river not as a waterway for beauty and enjoyment but as a back alley, a channel to carry away their unwanted waste.

Jardim Silvana Bangu Jardim Gramacho Guanabara Bay Senador Camará Tubiacanga Jardim Silvana RIO SARAPUÍ Guanabara Bay

Near a ragged, low-slung neighborhood called Jardim Silvana, the river passes a massive, modern water treatment plant, one of several that Cedae, the state company for water and sewage, is trying to expand and connect to more houses.

Jardim Silvana’s treatment plant.

But the grid is piecemeal. While the Sarapuí plant treats the waste of more than 300,000 residents, the sewage from neighboring Jardim Silvana spills into the murky Rio Sarapuí. It flows past the treatment plant uninterrupted.

Brown and lifeless, about 100 feet wide and moving almost imperceptibly, the river passes Jardim Gramacho, once South America’s largest open-air landfill. It was Rio’s main dump until its closure in 2012, receiving roughly 8,000 tons of garbage per day. Thousands of catadores, or garbage pickers, lived at Gramacho, turning it into a gang-infested slum. Now it is home to vultures and some of Greater Rio’s poorest citizens.

Maria de Lourdes Reis and her family near the Gramacho landfill.

Maria de Lourdes Reis has lived at the landfill, where her former husband worked, for more than 40 years. Her home, shared with two grown children, a daughter-in-law and five grandchildren, sits on hard dirt amid broken bricks and weeds. Sewage goes out a back pipe into weeds near a retention pond, where children swim, about a quarter-mile from the river.

Jardim Silvana Bangu Jardim Gramacho Guanabara Bay Senador Camará Tubiacanga RIO SARAPUÍ Jardim Gramacho Guanabara Bay

“Thirty years ago, we used to fish the Sarapuí River and swim,” de Lourdes Reis said. “The fish and the crabs were delicious.”

She does not remember the last time she went to the river.

“I just pass by on the bus,” she said. “People say that there are no fish anymore.”

She feels little connection to the Olympics, including the sailing events that will take place close to where Guanabara Bay meets the ocean, miles away from the Rio Sarapuí. Officials have scrambled to make that part of the bay as clean as possible by August, to avoid the public-relations nightmare of sick athletes or sailors colliding with flotsam in the middle of competition.

They have strapped so-called eco barriers, giant strainers to hold back garbage, across some river mouths to contain garbage and employed eco boats to troll the bay, scooping up all visible trash. Some rivers and canals have gates to hold back the rotten flow. There were plans to install several small-scale river treatment units, designed to capture and treat the worst of the sewage just before it reached the bay. Only one is in operation.

Much of the river’s trash ends up in Tubiacanga, a fishing village in Guanabara Bay.

Many miles north, not far from Rio’s international airport, the fishing village Tubiacanga, on Ilha do Governador (Governor’s Island), was once a thriving resort area, with bars, restaurants and sandy beaches.

Jardim Silvana Bangu Jardim Gramacho Guanabara Bay Senador Camará Tubiacanga RIO SARAPUÍ Guanabara Bay Tubiacanga

The shore is now slimy sludge, lined with trash. Most businesses are gone, leaving only crumbling foundations.

Across a short section of the bay is the river mouth where the Rio Sarapuí empties.

Several times a day, a shrinking number of fishermen wade into the water, climb into colorful wooden boats and check their baited hooks 200 yards offshore. The type and quantity of fish that they catch has dwindled over the years.

“I have 280 fish hooks,” said Gilson Alvarenga, who has fished the area for 30 years. “About 200 of them come up with garbage.”

The fishermen do not have far to look for the cause of their village’s demise. They, too, know that the bay is not the problem but the consequence.

“The problem,” Alvarenga said, “comes from the river.”