A Senate panel on Thursday advanced a bill that would allow the state to hire pharmacies to prepare lethal-injection drugs that some drugmakers won’t sell for executions.

But the proposal came under fire at an afternoon hearing from a law professor and advocates for the Virginia Press Association, who objected to provisions meant to shield the identity of the pharmacies. Critics said that hiding that information would make it harder to ensure that inmates were not subjected to faulty drugs and would prevent news organizations and others from scrutinizing death penalty practices and state purchasing.

In other states, such secrecy provisions have been intended to protect drug manufacturers from the political pressure that has prompted some of them to halt sales in the United States.

The administration of Gov. Terry McAuliffe (D) is seeking the measure. McAuliffe’s secretary of public safety, Brian Moran, said the secrecy provision was included in the proposal for “security” reasons.

The bill would allow the state to hire pharmacies to make the drugs. Currently, pharmacies can mix custom drugs only with a prescription for a specific patient for a therapeutic use.

The Senate Education and Health subcommittee that heard the bill voted to amend it to require that the state disclose what drug or drug combination is used in any execution. But it left intact the secrecy provision, which extends to the terms of the pharmacies’ contracts with the state.

“There ain’t a state in America that gives you the name of the guy who sticks the needle in any more than you got the names of the folks who pulled the switch when we had the electric chair,” said Sen. Richard L. Saslaw (D-Fairfax), the bill’s sponsor.

Saslaw said that the measure would help the state carry out executions in the most humane way possible.

“Would you like us to go back to the electric chair?” he asked when Corinna Barrett Lain, a professor at the University of Richmond School of Law, spoke against the bill.

Lain, a former prosecutor who described herself as “agnostic” on the death penalty, focused on the bill’s “secrecy provisions.”

“I think it’s extremely bad government to shroud in secrecy the state at its most powerful moment, which is exercising its sovereign right to take the life of one of its citizens,” she said.

After amending the bill, the subcommittee agreed to send it to the full Education and Health Committee, with the recommendation that it then move to the Courts of Justice Committee.

Under Virginia law, death row inmates have a choice between lethal injection and electrocution. If they don’t choose, the default method is lethal injection. An effort to make electrocution the default method failed during last year’s General Assembly session.

Virginia has a supply of the drugs needed for its lethal-injection cocktail, but the drugs will eventually expire or be used up, and there is no clear option for obtaining more, Moran said in an interview.

“We have all three right now. We could perform an execution by lethal injection right now,” Moran said. “But the drugs do expire and are difficult to obtain.”

Moran said the Department of Corrections has requested the bill in order “to implement the current law of Virginia, which is providing death row inmates a choice of lethal injection.”

Del. Scott A. Surovell (D-Fairfax) said he was concerned about the bill.

“From my point of view, whenever the government is putting a human being to death, we ought to have the absolute maximum amount of sunshine and make sure it’s done humanely, properly and with as much dignity as possible for such a thing,” he said.

After the electrocution debate in the legislature last year, Surovell submitted a Freedom of Information request asking the Department of Corrections for records related to drugs, execution protocols and other issues. He said the department denied most of his request, but a Fairfax County judge ordered the documents released. The department appealed. The state Supreme Court will consider next week whether to accept the appeal.

All 32 states that impose the death penalty primarily rely on lethal injection. States apply either single or dual-drug protocols that typically involve a fatal dose of an anesthetic or sedative, or a three-drug cocktails that add a paralyzing agent and then a caustic heart-stopping agent, according to the Death Penalty Information Center.

Controversy over the death penalty has created severe drug shortages in recent years, setting off a scramble by states to adapt workable new execution protocols and effective drug combinations.

In the most urgent example, European manufacturers opposed to capital punishment no longer sell barbiturates to prisons in the United States. Critics say a substitute sedative adopted by several states, midazolam, may be less effective at inducing coma-like unconsciousness.

At least three of the 35 people executed in the United States last year endured prolonged and apparently painful deaths. Last February, a convicted murderer in Oklahoma, Clayton Lockett, appeared to writhe and struggle before succumbing after 43 minutes, while in July, the bungled execution of Arizona double-murderer Joseph Rudolph Wood continued for 90 minutes.

In response, Ohio, Arizona and Kentucky have altered execution plans to shift away from midazolam, although it remains proposed for use by Alabama and Virginia.

Jenna Portnoy contributed to this report.