Maryland Gov. Larry Hogan (R) called Friday for a ban on hydraulic fracturing in the state, adding a new twist to a legislative debate over whether to prohibit the controversial gas-extraction method or extend a moratorium on it for another two years.

Hogan has said in the past that he would support the practice, commonly called “fracking,” in Western Maryland if he believed it could be done in an “environmentally sensitive matter.” At a hastily called news conference Friday, he said he did not think there was a way to frack safely, and therefore would support a bill to ban the practice altogether.

“The possible environmental risks of fracking simply outweigh any potential benefits,” Hogan said. “This legislation, I believe, is an important initiative to safeguard our environment.”

If Maryland bans fracking, it would be the third state to do so, joining New York and Vermont.

Before Hogan’s announcement, the Democratic-majority legislature had appeared unlikely to enact a ban this session. A bill to prohibit fracking passed the House last week 97 to 40 — a veto-proof majority that included eight Republicans. But there was resistance in the Senate from key members who feared a veto by the governor and instead wanted to extend the moratorium.

On Thursday, anti-fracking activists demanding a Senate vote on a ban blocked an entrance to the State House and were arrested as lawmakers made their way to the building.

Hogan said he decided to back a ban in part because the legislature’s regulatory review committee put a hold on fracking rules that the state proposed last year. He said those guidelines would have been the most stringent in the nation, strict enough to deter any companies from fracking in Maryland.

“I’ve decided that we must take the next step and move from virtually banning fracking to actually banning fracking,” the governor said.

Hogan said he also decided to back the ban because Senate President Thomas V. Mike Miller Jr. (D-Calvert) recently expressed support for letting jurisdictions hold a referendum in 2018 on whether to allow fracking locally.

He was referring to a bill sponsored by Senate environmental committee chair Joan Carter Conway (D-Baltimore) that would also extend the moratorium on the gas-extraction method that is to expire in October.

“I am not for fracking, never have been for fracking, never will be for fracking,” Miller said in a statement. “The advocates for fracking have claimed that the people of Western Maryland are for fracking, and I believed it was important to let those residents’ opinions be heard.”

A Washington Post-University of Maryland poll last fall found that Marylanders opposed fracking by a 2-to-1 margin. Big majorities of independents (66 percent) and Democrats (69 percent) were opposed. But Republicans supported fracking, 49 percent to 36 percent.

Del. Wendell R. Beitzel (R-Garrett), one of the legislature’s strongest opponents of a fracking ban, said he was “very disappointed” with the governor’s move. “I guess the war on Western Maryland is not over,” he said.

Mike Tidwell, director of the Chesapeake Climate Action Network, said he was shocked by Hogan’s announcement but also pleased. The governor’s decision “sends a message to West Virginia, Virginia, California and Ohio, who have seen the negative impacts of fracking,” Tidwell said.

Conway said Friday that advocates were told this week that bills calling for a ban and a moratorium would be on the Senate floor next week. She also told them that, given the governor’s position at the time, they would need a veto-proof majority.

Conway said Friday that the ban would not have to wait if Hogan issued an executive order.

Del. Kumar P. Barve (D-Montgomery), chairman of the House Environment and Transportation Committee, said that Hogan’s decision removes the “last obstacle” to enacting a fracking ban. “I would advise the Senate to move either the House bill, Zirkin’s bill or both,” Barve said. “Zirkin’s bill” was a reference to a ban introduced in the Senate by Sen. Robert A. Zirkin (D-Baltimore County), which had stalled in Conway’s committee.

“We only need 24 votes in the Senate, and we have that,” Barve said.

Scott Clement contributed to this report.