RICHMOND — The Virginia Senate on Tuesday passed a bill that would make the state the eighth in the nation to require women to undergo ultrasound imaging before having an abortion — a high-profile conservative priority for which Gov. Bob McDonnell helped broker a compromise.

The measure passed by a 21-19 vote over the objections of Democrats, who said women should not have to go through a medically unnecessary procedure to exercise a constitutional right and that the government should not be in the business of telling doctors how to do their jobs.

The final vote was largely along party lines. Democrats Charles J. Colgan of Prince William and Phillip P. Puckett of Russell allied themselves with Republicans, and one Republican, John C. Watkins of Powhatan, voted against the measure.

Legislators, at the behest of Mr. McDonnell, removed a provision from the original bill that could have forced women to undergo an invasive transvaginal procedure after the bill drew national attention and mockery from late-night comedians.

Mr. McDonnell said he was “pleased” that the bill passed.

But Ms. Howell said that, even in its current form, the bill was unacceptable.

“Very rarely do I get angry,” she said. “But I am angry about this bill.”

The bill has passed the House of Delegates, but because the Senate amended it, it must be approved again by the House before it heads toMr. McDonnell’s desk.