State Sen. A. Benton Chafin Jr. (R-Russell) in Richmond in 2015. (Bob Brown/Richmond Times-Dispatch/AP)

The Republican-controlled Virginia Senate voted Tuesday to repeal an old law banning guns — as well as bowie knives, daggers and other weapons — from places of worship.

Sen. A. Benton Chafin Jr. (R-Russell) said the “archaic law,” thought to date to Colonial times, treads on the private-property rights of churches. He also said it threatens the safety of worshipers, noting the massacre of 26 people at a Texas church in November.

“For any of us to sit here and think that when a gunman comes to you that a law is going to somehow protect you is sheer lunacy,” Chafin said during the floor debate.

The measure passed along party lines, 21 to 18, with one Democrat absent. The bill now heads to the House, which like the Senate is narrowly controlled by Republicans.

Through a spokesman, Gov. Ralph Northam (D) signaled he will veto the measure if it reaches his desk. “The governor is ready to work with the General Assembly to promote responsible gun ownership, but he does not believe more guns in more locations is a solution to the real problem of gun violence,” Northam spokesman Brian Coy said.

State law prohibits carrying “any gun, pistol, bowie knife, dagger or other dangerous weapon, without good and sufficient reason, to a place of worship.”

In 2011, then-Attorney General Ken Cuccinelli II (R) issued an opinion that the ban would not apply to someone with a ­concealed-carry permit, Sen. J. Chapman “Chap” Petersen (D-Fairfax) noted during an extended debate.

“Attorney generals come and they go,” Chafin replied, suggesting that worshipers could not rely on that opinion as legal protection if they carried a gun to church. He contended that under the current law, places of worship could not station armed security guards in their buildings.

Sen. Jeremy S. McPike (D-Prince William) offered what he said would be a better solution. He wants to ban worshipers from carrying weapons unless they have authorization from the house of worship. He sponsored a bill to that effect, but it died in a Senate committee last week.

Chafin said that if his own bill passed, churches could still choose to ban weapons from their premises.

Petersen, a lawyer who has represented churches in litigation, warned that churches, mosques and synagogues would be plunged into great controversy if guns became an option.

“Trying to decide whether you pass the collection plate from the left side or the right side is oftentimes an issue of controversy,” he said. “We’ve got plenty of issues already.”