The bill passed the Republican-controlled Senate by a 22-17 vote. The Republican-dominated House has already approved the measure.
After a lower chamber vote on a minor amendment, the measure will go to Democratic Governor Terry McAuliffe for approval. A spokesman for the governor said the measure would be reviewed when it arrived.
Virginia is one of eight states that allows electrocution as a method of execution, letting condemned inmates choose between it and lethal injection. If they do not choose, lethal injection is used.
Virginia, along with other states, has struggled to get lethal injection drugs because pharmaceutical companies have protested their use in executions.
See the most controversial death penalty cases:
Controversial Death Penalty Cases
Virginia Senate approves electric chair amid drug shortage
Dave Atwood, left, and Sophia Malik, right, both of Houston, hold photos of Napoleon Beazley as they protest his execution Tuesday, May 28, 2002, in Huntsville, Texas. Beazley, 25, was executed by lethal injection for the 1994 carjacking murder of 63-year-old John E. Luttig of Tyler, Texas. It was the 14th execution this year in Texas. (AP Photo/Brett Coomer)
Rena, left, and Ireland Beazley hold a photo of their son Napoleon Beazley at their home in Grapeland, Texas, Friday, May 31, 2002. Napoleon Beazley's death sentence for killing the father of a federal judge during a 1994 carjacking at age 17 stirred national debate over capital punishment for youths. (AP Photo/Donna McWilliam)
Rena Beazley, left, and her husband, Ireland, from Grapeland, Texas, are shown in the audience during a news conference Thursday, May 23, 2002, in Austin, Texas. The two, parents of Texas death row inmate Napoleon Beazley, and clergy pleaded for his sentence to be commuted to life in prison. He is scheduled to be executed by lethal injection Tuesday. (AP Photo/Harry Cabluck)
Mugshot of Cameron Todd Willingham
(Photo credit: Texas Department of Criminal Justice)
Judy Cavnar, of Ardmore, Okla., a cousin of executed Texas prison inmate Cameron Todd Willingham, displays a picture of him during a news conference Tuesday, May 2, 2006, in Austin, Texas. The case of a Willingham, who maintained his innocence until the end but was executed after he was convicted of an arson murder, is going before a new state commission required to look into allegations of forensic misconduct. (AP Photo/Harry Cabluck)
Eugenia Willingham of Ardmore, Okla., right, wipes a tear as she speaks during a news conference Tuesday, May 2, 2006, in Austin, Texas. Willingham and other relatives of Cameron Todd Willingham recounted the final moments of Willingham's life and their unsuccessful attempts to block his execution. The New York-based Innocence Project submitted the case to the Texas Forensic Science Commission on Tuesday and also asked the panel to review arson convictions statewide. In the background, from left are Willingham's cousins, Pat Cox, and Judy Cavnar. Mrs. Willingham is his stepmother. (AP Photo/Harry Cabluck)
Death row inmate Troy Davis appears in this undated file photo provided by the Georgia Department of Corrections. (Georgia Department of Corrections/MCT via Getty Images)
Demonstrators gather in front of the White House in Washington as they hold a vigil before the scheduled execution of death row inmate Troy Davis, Wednesday, Sept. 21, 2011. Davis is facing lethal injection for killing an off-duty Georgia policeman in Savannah, a crime he and others have insisted for years that he did not commit. (AP Photo/Charles Dharapak)
A man chants during a vigil for Georgia death row inmate Troy Davis In Jackson, Ga., Wednesday, Sept. 21, 2011. Davis is scheduled to die Wednesday for the killing off-duty Savannah officer Mark MacPhail. (AP Photo/John Bazemore)
Anne MacPhail pauses for a moment after learning at 10:55 p.m., on September 21, 2011, that the U.S. Supreme Court had denied a stay of execution for Troy Davis, who was convicted in the 1989 murder of her son Mark MacPhail. Davis was executed shortly after in Jackson, Georgia. (Robin Trimarchi/Columbus Ledger-Enquirer/MCT via Getty Images)
Mugshot of Kelly Renee Gissendaner
(Photo credit: Georgia Department of Corrections)
Discover More Like This
BACK TO SLIDE
The last death row inmate in Virginia to choose the electric chair for execution was in 2013.
Inmate Ricky Gray, who killed six people in Richmond in 2006, had been scheduled for execution on March 16, adding urgency to the legislative debate.
Gray's execution has been postponed by the 4th U.S. Circuit Court of Appeals, pending a decision by the U.S. Supreme Court about whether to hear the case.
Gray has not indicated which method of execution he preferred.
The legislation has fueled debate in Virginia over whether capital punishment, especially the electric chair, constitutes cruel and unusual punishment.