RICHMOND, Va. -- The Virginia Senate has advanced legislation that would allow authorities to take guns away from people deemed dangerous to themselves or others.

The Democratic-led Senate gave preliminary approval to approved the so-called “red flag” law. SB 240 would create a process for attorneys and law enforcement to file emergency orders prohibiting a person from purchasing, possessing or transferring a firearm if they pose “a substantial risk of injury to himself or others.”

The move comes a day after tens of thousands of gun-rights activists rallied peacefully at the state Capitol.

The measure is set for a final vote in the Senate before going to the House.

Republicans blasted the bill as an assault on gun rights and civil liberties.

Democrats said the bill was a thoughtful measure that would preserve due process while also protecting people against potential gun violence.