ATLANTIC CITY — A judge on Thursday shut down a government sand-dune construction project in New Jersey that created huge ponds of bacteria-laden water and blocked off access to parts of the beach.

Superior Court Judge Julio Mendez said he was horrified by photos showing "lake-like" ponds of standing water on the beach in Margate for days following heavy rains last weekend. He agreed that residents of the town just south of Atlantic City are suffering irreparable harm and that the situation cannot be allowed to be made worse, and said he is halting the project for at least a week.

"Some of those photos are pretty horrendous," Mendez said. "It's lake-like ponding causing tremendous difficulty. Something went really bad here. The bottom line is this needs to be corrected."

The work is part of a statewide effort to protect New Jersey's 127-mile coastline following the devastation that Superstorm Sandy caused in 2012. But Margate has opposed it as unnecessary and harmful to its shoreline, and now a public health hazard.

Some critics have dubbed the water formation "Lake Christie" after the governor that has championed the dune work.

The judge ordered all sides to work out a remedial plan, to be presented to him next Thursday.

"I'm ecstatic," Margate Mayor Michael Becker said. "It's the right thing to do. To allow them to continue to do something that's not working is wrong."

The city's government voted on Wednesday to seek a court order forcing the state Department of Environmental Protection to immediately halt the work, which has covered about half of the 2-mile (3.2-kilometer) long beachfront. The mayor estimated about a third of the beachfront is inaccessible to beachgoers.

The ponds of standing water were exactly what Margate residents had warned of in previous, unsuccessful litigation against the government's plan to build the protective sand dunes there.

Although the U.S. Army Corps of Engineers was not a defendant in Thursday's court action, the judge ordered that they be added to the case. The New Jersey state attorney general's office and the U.S. Attorney's Office, on behalf of the Army Corps, declined comment.

When weekend storms dumped nearly a half foot of rain on Margate, water quickly collected in excavated areas between the dunes and the wooden bulkhead that separates oceanfront homes from the sand. Some were two or more feet deep, and lingered until the Army Corps began pumping them out on Tuesday. Most of the water had been removed by Thursday, although the areas where it had been remained sodden.

Becker said the city's testing of water from the ponds found "off the charts" levels of bacterial contamination. He said two lifeguards had contracted bacterial infections by sloshing through the dirty water this week, and are out sick from work.

The water from the ponds was pumped into the ocean, but David Apy, assistant state attorney general, said samples of ocean water were 90 percent below the level needed to order beach closings.

He did, however, acknowledge that digging the retention ponds behind the dunes to the depth that was done might have been too much, raising the level of groundwater on the beach and giving the runoff no place to go.

This weekend's forecast calls for more rain.

Also on New Jersey 101.5:

More From New Jersey 101.5 FM