The bill had previously been approved by both chambers, but a modified version with a minor amendment was given final approval Friday.
Virginia is one of at least eight states that allow electrocutions, but currently gives inmates the choice of lethal injection or the electric chair. If they don't choose, they receive the injection.
Like many states, Virginia has struggled to obtain lethal-injection drugs in recent years because drug companies have protested their use in executions.
Democratic Gov. Terry McAuliffe has not indicated whether he will sign the bill into law.