SEAFORD, VA. — It looks like a mad scientist's lab, something straight out of a sci-fi novel. Valves turn in every direction. Tubes are stacked halfway to the ceiling. Tiny bubbles dance in large vats of water.

But what's happening in a hangar of the York River Treatment Plant is real, part of a grand experiment that could help keep this coastal region from continuing to subside and eventually be claimed by the rising sea. Over the next 15 months, tests will determine whether millions of gallons of wastewater can be purified to drinking water quality and injected into the ground.

If successful, the project of the Hampton Roads Sanitation District could start to replenish a giant aquifer that thousands of industries and half a million households in the area are sucking dry. Over the past five decades, they've collectively pumped out so much water that land here is falling 4 millimeters a year — or more than 1½ inches by 2026.

Ted Henifin's jaw-dropping, eyebrow-raising idea was first proposed in 2015, and last month the sanitation district general manager kicked off its pilot phase to stop what some scientists have called a nightmare in super slow motion.

Aquifers big and small exist under Hampton Roads in muddy pockets between thick layers of earth. Pressure is relieved as water is pumped out, causing the layers, and then the land, to sink. As that geological drama played out for nearly a century, sea levels influenced by global warming crept up, to the point today where schools, homes and other property are threatened with sometimes catastrophic flooding.

Although Henifin's project still faces a multitude of regulatory challenges from the federal Environmental Protection Agency and the Department of Justice, Henifin bills it as the best plan yet to rescue the aquifer and halt land subsidence.

"The project will be full scale between 2020 and 2030," he said. "It will be the biggest aquifer recharge in the country, more than 100 million gallons per day."

The unsustainable use of groundwater is often thought to be a concern only out West, where farmers in California's San Joaquin Valley have pulled so much water from aquifers since the 1920s that land has sunk by as much as 28 feet.

[No working water and no working solutions plague California's driest county]

Yet what's happening in Norfolk, Virginia Beach, Portsmouth and the other cities that make up Hampton Roads is eerily similar. Wells are pumping about 100 million gallons of water a day out of local aquifers.

"If we continue to remove the amount of water that we're removing now, in the future those aquifers won't be very useful," said Greg Hancock, a hydrology professor at the College of William and Mary. He thinks that irreversible damage could take only a few decades — or a few years. "They'll never be able to hold as much water as they used to."

As the water table falls, so does the ground. Rising seas tied to human-caused warming are causing the Atlantic Ocean and Chesapeake Bay, along with big rivers such as the York, James and Elizabeth, to creep up and flood communities even when rainfall is light.

Along the Atlantic Coast, a hole has been drilled by the United States Geological Survey to assess the issues of groundwater pumping, relative sea-level rise and land subsidence. (YouTube/USGS)

In fact, besides New Orleans, Hampton Roads' population is more threatened by sea-level rise than any other in the nation.

With the Sustainable Water Initiative for Tomorrow, or SWIFT, Hampton Roads would follow California, as well as arid Saudi Arabia and Australia, in pumping purified wastewater into aquifers to counterbalance massive withdrawals of groundwater.

The lab at the York treatment plant is what Henifin calls a "pipe gallery." It hums as wastewater flows through two different processes — reverse osmosis and carbon filtering — to determine which can remove the most nutrients and unmentionable stuff more efficiently.

"I see it as a complex scientific and technical process all lined up to remove everything that can be removed from water," Henifin said.

The project boils down to punching about 30 holes about 500 feet down, deep enough to reach the level where Hampton Roads wells pump water, and injecting treated water.

[In Norfolk, evidence of climate change is in the streets at high tide]

Groundwater in Hampton Roads is mostly pumped from the Potomac Aquifer, the deepest part of the North Atlantic aquifer system that starts in northern North Carolina and stretches to New York's Long Island.

The system is among the smallest of 66 principal aquifer systems in the United States but one of the most heavily used. It ranks 13th for the amount of water that's pumped and seventh for the number of people it serves.

Although 500,000 households in and around Hampton Roads rely on the aquifer, 60 percent of the water is taken by a few businesses and municipalities. They include the West Point and Franklin paper mills, the Colonial Williamsburg Foundation and James City Service Authority.

Over the past 100 years, artesian wells have gone from pumping water from 31 feet above sea level to 200 feet below it. With concerns about sinking groundwater and land, the state Department of Environmental Quality moved to dramatically cut water-withdrawal permits last year.

That, in turn, has threatened to stifle commercial development in more rural areas that are cut off from surface water. "We're going to abandon growth in this part of the state," Henifin said.

The sanitation district is proposing to use wastewater created by all of its 1.7 million customers, the majority of whom don't use groundwater, to recharge the aquifer.

In his pitch to federal regulatory officials, Henifin stressed that purifying wastewater has benefits beyond saving the aquifer and arresting land subsidence, such as reducing the polluted sewage that enters Chesapeake Bay tributaries. He moved ahead with the pilot even without a go-ahead from EPA Region 3.

Nor does the district yet have Justice Department permission for switching how it will comply with a consent decree to reduce polluted wastewater in the Bay — by cleaning shower and toilet water instead of improving underground pipes.

When two scientists at the U.S. Geological Survey learned about SWIFT, they were not convinced that the sanitation district could match the chemistry of its purified water with the land subsidence related to the aquifer.

[With its fresh water running dry, wealthy Santa Barbara desperately turned to one last source — the ocean]

Hydrologists Jack Eggleston and Jason Pope learned that the Hampton Roads sanitation district had the same concerns. For decades, the USGS had wanted to build a device to measure land subsidence but couldn't afford it. Eggleston and Pope discovered the Hampton Roads sanitation district would be willing to pay $1.3 million for a new extensometer.

USGS allowed them to leave their respective stations in Richmond and Indiana to monitor SWIFT. The deep well drilled for the extensometer can also be used to study the aquifer's water chemistry.

"There will be some chance factors," Eggleston said. "When they inject water at wells, it will move away from there in all directions," traveling south beneath Elizabeth City, N.C., and north toward Richmond. "As it moves, the chemistry will change."

On a recent weekday, both men were wearing hard hats and smiles as they watched a giant well being constructed at the district's water treatment plant in Suffolk.

"Are we excited? Yes," said Eggleston, who had been pushing for this since 2009. "Groundwater is fabulous, because it's fresh almost everywhere, drinkable everywhere," he said. But extracting it can cause major problems. "Measuring it is really important. You want to know what's happening so you can take action."