The Virginia Senate narrowly approved Tuesday a modified version of a contentious proposal that would require women to get an external ultrasound before an abortion.

The 21 to 19 vote, mostly along party lines, came a week after Gov. Robert F. McDonnell (R) asked legislators to revise the bill following protests on Capitol Square and repeated mocking on national television. Lawmakers amended the original bill, which mandated that women undergo a transvaginal ultrasound, a procedure that requires a probe be inserted into the vagina.

Democratic Sens. Charles J. Colgan (Prince William) and Phillip P. Puckett (Russell) voted with Republicans in favor of the scaled-back measure. One Republican, Sen. John C. Watkins (Chesterfield), voted with Democrats against it.

In a long and impassioned debate Tuesday, Democrats argued that the ultrasound procedure would be unconstitutional and costly, and that it was merely designed to discourage women from seeking abortions.

“Women who want to have abortions will go to back alleys. Women will die,’’ Sen. L. Louise Lucas (D-Portsmouth) admonished her colleagues. “They are not going to let you tell them what to do with their bodies.”

The bill will head back to the Republican-led House of Delegates, which already voted for similar measures this year and is widely expected to do so again. McDonnell, who signed legislation last year that imposed new regulations on clinics that perform abortions, told reporters that he will review the legislation but supports the concept.

“I think women have the right to know all of the medical information before they make a very important choice,’’ McDonnell said.

The Senate amended the bill to exclude women who have reported to law enforcement agencies that they are victims of rape and incest, but it did not exempt women who know that their babies would suffer from birth defects.

“The purpose of the bill is to make sure the mothers have more information as to the gestational age and physical development before making a decision as to the abortion,’’ said Sen. Stephen H. Martin (R-Chesterfield), who spoke during the debate.

A series of other amendments died that would have forced insurance companies to cover the cost of the ultrasounds or required the state to pick up the tab for women without health insurance. Lt. Gov. Bill Bolling (R), who presides over the equally divided Senate, cast three tie-breaking votes on the amendments.

Opponents of the bill, including Planned Parenthood Advocates of Virginia, NARAL Pro-Choice Virginia and the American Civil Liberties Union, said they have not decided whether to challenge the legislation in court should McDonnell sign it. Seven other states have similar laws.

Republicans, who control both chambers of the General Assembly, have considered several abortion-related measures in the 60-day legislative session. But most, including those ending state subsidies for low-income women to abort fetuses that have serious birth defects and giving rights to fertilized eggs, have been killed.

The House and Senate had already approved versions of the ultrasound legislation. But a national uproar over the measure and opponents’ graphic detail of the ultrasounds in early pregnancies led McDonnell — an abortion opponent — to intervene.

An abdominal — or “jelly-on-the-belly” — ultrasound before an abortion would still be required. Both abdominal and transvaginal ultrasounds are already used by most abortion providers.

Sen. Janet D. Howell (D-Fairfax) described the original version of the bill as “state rape’’ and said the new version is tantamount to “state assault.”

“Very rarely do I get angry, but I am angry about this bill,’’ she said. “It reflects an attitude that is demeaning to women. It presumes the legislature — which as we look around is virtually all male — knows better what should happen to a woman’s body than the woman herself and her physician.’’

Sen. Richard L. Saslaw (D-Fairfax) tried unsuccessfully to have the measure be reconsidered next year — a maneuver that has worked on other contentious bills.

“This is just a senseless procedure to make some people, I guess, feel good and put another obstacle up in the way of people who are trying to access that process,’’ Saslaw said. “It serves no useful purpose.”

The debate was postponed Monday after Republicans hunted for votes. By Tuesday, the vote was widely expected, and responses from advocacy groups came minutes after the legislation passed.

“Pro-life Virginians, not cast members of ‘Saturday Night Live,’ sent legislators to this General Assembly through their vote to pass legislation like this because they understand that abortion is an invasive and risky procedure and that the abortion industry simply cannot be trusted put the woman’s health and safety ahead of its profits,’’ said Victoria Cobb, president of the conservative Family Foundation.