New Jersey has now banned drilling for oil and natural gas in state waters -- and taken a step aimed at preventing President Donald Trump's administration from allowing drilling farther offshore.

Gov. Phil Murphy signed a bipartisan bill into law Friday that prohibits drilling in the three miles of ocean water that the state controls along the Atlantic coast.

And though the state cannot ban drilling in federal waters, this law also prohibits the state from approving any facilities or infrastructure related to drilling to be built in New Jersey -- including pipelines and docks.

Murphy said that will make it "awfully hard" for drilling in wters beyond the Garden State's jurisdiction.

The move comes a few months after Trump's administration announced it would open nearly all U.S. water to new offshore drilling to expand the nation's energy resources.

New Jersey is one of a few states that have been pushing local legislation as a back-door way to stop Trump, a Republican.

But Murphy's office said New Jersey is the first state to enact such a broad ban. California prohibits drilling in state waters but not facilities related to drilling.

"We should not play games with the health of the Jersey Shore," Murphy, a Democrat, said before signing the measure in a ceremony on the Point Pleasant Beach boardwalk, with the Atlantic Ocean stretching behind him.

Murphy noted he signed the bill (A839) on the eighth anniversary of the Deepwater Horizon spill, which dumped millions of gallons of oil into the Gulf of Mexico. It was the largest oil spill in American history.

The goal, Murphy stressed, is to prevent that from happening along New Jersey's 130 miles of shoreline, which is a big part of a state tourism industry that generates $4 billion a year and is home to hundreds of thousands of jobs.

"Our coast is a national treasure and the home of so many personal memories of millions of people and livelihoods," Murphy said. "Today and together we're making sure the Jersey Shore remains a place where only good memories are made."

The law also requires the state Department of Environmental Protection to review any proposed oil or natural gas development in the Atlantic region of the U.S. to see if it will affect New Jersey waters.

Supporters of drilling say it would give the U.S. more ways to generate energy and create new jobs, while also lowering energy bills.

But even Murphy's Republican predecessor, former Gov. Chris Christie -- a longtime Trump friend and adviser -- stood alongside Murphy in January to oppose the president's drilling plans.

And the New Jersey Legislature overwhelmingly passed this bill with broad bipartisan support.

Environmentalists and lawmakers from both major political parties stood next to Murphy at Friday's event.

State Assemblyman R. Bruce Land, D-Cape May, said an oil spill would "damage the fragile marine ecosystem, kill off endangered and threatened species of fish and wildlife, and poison the many types of fish and shellfish that New Jersey residents and visitors eat and harvest for sale."

State Sen. Troy Singleton, D-Burlington, said "we need to do whatever it takes to protect" those things.

Despite Trump's order, U.S. Interior Secretary Ryan Zinke told the state's federal lawmakers in February that they shouldn't expect drilling off New Jersey's shores.

U.S. Rep. Chris Smith, R-1st Dist., said "you never know when" that "not likely turns to likely."

"We now have a law to make it nearly impossible," Smith said.

U.S. Rep. Frank Pallone, D-6th Dist., agreed.

"Until I see an ironclad statement, on paper, in law, that this is not gonna happen, I'm not going to trust it," Pallone said. "It is important we get tough and say this is not acceptable."

But Murphy and environmentalists say they need other states along the coast to enact similar legislation.

"We know an oil spill off the Jersey Shore would have impacts 100 miles away, just as a spill off the coast of Maryland or Virginia or Florida would foul our beaches," Murphy said.

California, New York, Rhode Island, and South Carolina are among the states considering similar laws.

Jeff Tittel, director of the New Jersey chapter of environmental group the Sierra Club, called New Jersey's law "an important first step." But he stressed that oil companies could still drill in federal waters off the state's coast and ship the oil to other states.

Getting other states on board, Tittel said, would help "build a blockade" to stop drilling.

Murphy said his administration plans to "turn the heat up" on other states.

Brent Johnson may be reached at bjohnson@njadvancemedia.com. Follow him on Twitter @johnsb01. Find NJ.com Politics on Facebook.