Texas politicians have given final approval to one of the US's toughest anti-abortion bills, but opponents are set to challenge the legisation in federal court.

More than a thousand pro-choice and anti-abortion demonstrators packed the state capitol in Austin late on Friday night as senators voted on legislation that has made Texas the focus of nationwide abortion-rights activism.

The senate passed House Bill 2 by 19 votes to 11 just before midnight local time. Texas governor Rick Perry is now due to sign it off.

"The key will be what the courts will do," Sylvia Garcia, a Democratic senator for Houston and a former judge, said before the vote. "I think the Texas proposal is on a path to litigation, to being held unconstitutional. We'll have to wait for the courts to ultimately decide."

Last Monday a federal judge issued a ruling temporarily blocking the introduction of a new abortion law in Wisconsin. Like the Texas plans, the law calls for doctors who perform abortions to have admitting privileges at a nearby hospital. The Texas bill also insists that clinics upgrade to meet the standards of ambulatory surgical centres and bans abortions after 20 weeks.

Republicans blocked attempts by Democrats to dilute the measures on Friday, including an amendment that would have allowed exceptions to the 20-week limit for victims of incest or rape.

When Davis, her fellow Democrats and noisy protesters successfully stalled an attempted vote on the original bill on 25 June, Perry swiftly recalled lawmakers for a special session lasting up to 30 days to give the proposals another chance to pass.

Perry said on Fox News last Sunday that the shouting that scuppered the vote was "mob rule". During this session, which began last week, officials have been strictly enforcing a ban on what they consider to be disruptive conduct. But there was no silencing the crowds who gathered on all four floors of the capitol's huge rotunda on Friday for the climax of weeks of protests and rallies related to the bill, creating a heady, unruly atmosphere.

Many chanted slogans and songs and brandished banners. Some of the anti-abortion activists held up placards referencing the Bible. Those against the bill wore orange, and those who termed themselves "pro-life" dressed in blue.

By mid-afternoon the orange demonstrators heavily outnumbered the blues and the queue to enter the gallery stretched along a staircase and almost to the end of one wing of the statehouse, with hundreds standing for hours in the hope of seeing the proceedings. There was silence in the halls when Wendy Davis spoke shortly after 11.30pm. "Tens of thousands of Texans will not be able to make the long drive, sometimes hundreds of miles, to the closest clinic," she said. "We are about to take away from victims of rape and incest a chance to reclaim their lives."

For a time, troopers even took away tampons on the basis that they could be used as missiles. Garcia believes that the publicity generated by the bill and the degree of dissent marks "a tipping point for women in Texas and across the country". The 62-year-old said the legislation is "part of an extreme agenda by radical right groups who would prefer to ban abortions around the country".

Democrats argue that the bill will force the closure of all but five of the state's 42 abortion clinics, resulting in a loss of access to other family-planning services they provide, such as advice and disease screening.

Opponents also claim it will force women in rural areas to travel vast distances or seek medical help from black-market sources. However, those in favour say that tightening regulations will help protect women if complications occur.

"It's not just about abortion, it's about women's healthcare and whether we allow government to chip away at constitutional rights," Garcia said. She accused Texas Republicans of putting women's safety at risk to satisfy personal political ambitions.

After the vote, Davis tweeted: "The fight for the future of Texas is just beginning." There are rumours that she may run for governor next year.