NEW YORK (AP) — Amid the crammed concrete and steel of Brooklyn, a ribbon of clear water stretches out into a vast bay. Tall grass rustles along the undulating shoreline, where bursts of golden flowers, pines and cacti flourish in the soft sand.

"This is what would have been here pre-us. Pre-European development," said John McLaughlin, director of the office of ecological services at New York City's department of environmental protection.

Just a few years ago, the tributary, known as Paerdegat Basin, was a fetid mess. The water was murky green, teeming with 1.8 billion gallons of sewage and rainwater that streamed in during storms. The working-class neighborhoods along the waterway stank like an outhouse during hot weather and low tide. The shoreline was strewn with rusted out cars, garbage and broken bottles.

"It was a junkyard. It was a chop shop," McLaughlin said. "It was a weed-strewn mess, full of invasive plant life. And boy, did it smell."

The Paerdegat tributary feeds directly into Jamaica Bay, a body of water and marsh sandwiched between Brooklyn and Queens, and on the shores of which sits Kennedy International Airport. Part of the area is run by the city; the other is Gateway National Recreational Area, which contains a wildlife refuge with one of the most important bird sanctuaries in the Northeast.

And now a decade-long $455 million investment by the city to clean up Paerdegat Basin is nearly complete, including a new sewage overflow retention facility at the head of the 1.3-mile-long channel and 52 restored acres of native grasslands and wetlands.

In older cities like New York, sewer systems are built on one pipe that handles both rainwater and sewage. With considerable concrete and not enough exposed earth to absorb rainwater, the combined runoff often overflows and backs into city waterways.

The new retention facility is capable of preventing 50 million gallons of wastewater per storm that would previously have streamed into the water and out to the bay. It was completed first and has been operational since 2011. Automated, state-of-the-art machinery clicks on when water levels rise too high. Giant rakes segregate large sticks, bottles and other refuse from the pooling wastewater, which is then collected and stored in giant underground tanks. After the storm subsides, the water is pumped out to a treatment facility and cleaned, and sent out the waterways.

The facility is spotless. Even the air is filtered, so there's no smell.

"That's the best compliment you can give us," said Chris Laudando, the chief of collections facilities for southern Brooklyn.

It has reduced the amount of wastewater spilling into the channel from 1.8 billion gallons annually to about 650 million, said Vincent Sapienza, deputy commissioner of the Department of Environmental Protection. That means better water quality in the basin and out to the bay and a better habitat for birds and fish that live there.

The idea for the project was first discussed in the mid-1990s, but took until 2005 to get off the ground. Conservationists have praised the project as forward-thinking and inclusive. Dan Mundy of the Jamaica Bay Ecowatchers, a watchdog group for Jamaica Bay and its tributaries, said he has noticed a visible change in the bay.

"We're very excited," he said. "I think it's a big deal, the work that went into the project is paying off and now it's an area really to be enjoyed."

The construction on the channel began after the retention facility. Crews dredged the filthy sediment and cleared the shoreline of refuse, then used sand excavated for the retention facility to form the hills. The department of environmental protection planted more than 100,000 plugs of grassland and wildflowers, more than 5,300 shrubs and nearly 1,100 trees.

Then, they waited for the fragile seedlings to grow. The result is a mass of soft golds and greens that reflect off the water. Goldenrod and smooth cord grass are now about waist-high. Atlantic white cedars grow among little blue stem, American holly and the eastern prickly pear— the only cactus native to the Northeast. McLaughlin said he used historical biology records to decide what to plant.

"It's very satisfying to see a project you've been talking about since the '90s come into being," he said.

The department of environmental protection will turn the acreage over to the city parks department in the upcoming months, and it will remain closed to give plants enough time to take proper root. Five acres will eventually be open for educational tours as an ecology park, and the rest will stay natural to encourage wildlife growth, though no opening date has been set.