* Bill bans most abortions after 20 weeks of pregnancy
* Republican Governor Rick Perry certain to sign
* Political battle stirred national debate, filibuster (Adds details on the bill, protests)
Texas' Republican-controlled Senate has voted to ban most abortions after 20 weeks of pregnancy, ending a high-profile political battle that stirred debate over abortion rights well beyond the state's borders.
Already approved by the House, the sweeping bill to restrict abortions now goes to Republican Governor Rick Perry, who is certain to sign it and had called a second special session of the legislature to get it through.
It makes Texas the 13th U.S. state to pass a 20-week ban. The 20-week provision is based on disputed research suggesting fetuses feel pain at that point in a pregnancy. Current limits are 26 weeks in Texas.
The Senate passed the measure late on Friday by a vote of 19 to 11 in front of a full public gallery while protesters yelled and chanted outside the chamber.
The issue has stirred huge attention, including internationally, in part because of an 11-hour filibuster in June against the bill by state Senator Wendy Davis, a Democrat. Her actions at the time prompted comparisons with the James Stewart movie "Mr Smith Goes To Washington".
Despite political support in Texas for the bill, there could be legal hurdles. Courts have blocked the ban in three of the 12 states that passed it, and opponents of the Texas bill vowed to challenge the decision in court.
Thousands of activists for and against the bill gathered at the state capitol this summer for rallies and marches and to testify at public hearings.
"Let's draw the line and not torture these babies that are aborted," bill supporter Senator Bob Deuell, a Republican and a family physician, said during Friday's nine-hour debate.
The Texas measure would change standards for abortion clinics in ways that opponents say would cause dozens of the facilities to shut down, forcing Texans to turn to illegal, unsafe means. Bill supporters disagree that clinics would have to close.
"This bill is creating a situation where women in Texas today not only will not be made safer but they will absolutely be at risk of their health," said Davis.
The bill also requires doctors performing an abortion to have admitting privileges at a hospital within 30 miles of the abortion clinic. Supporters of that provision said it was important in case complications arose in an abortion and the woman needed to be hospitalized.
The Texas legislation also calls for stricter guidelines for how doctors administer abortion-inducing drugs, such as the regimen known as RU-486.
The pink granite statehouse was packed on Friday, with Texans opposed to the bill wearing orange and holding signs that said, "My body, my choice," some of them jumping, chanting and loudly shouting outside the Senate chamber.
Those supporting the bill wore blue, some carrying Bibles and crosses and holding signs that said things like, "Unborn babies feel pain."
"What happened here tonight is going to fast-forward change in Texas in the long run, but unfortunately a lot of women will suffer in the process," said Cecile Richards, president of Planned Parenthood Federation of America.
Perry called lawmakers back to Austin for a second special session to reconsider the proposal after Davis's successful filibuster, and this time lawmakers were not fighting the clock. The second special session began July 1 and could last up to 30 days.
"Today the Texas legislature took its final step in our historic effort to protect life," Perry said in a statement.
The Texas Department of Public Safety increased security for Friday's debate, searching bags of everyone who entered the Senate gallery. The department said officers found 18 jars containing what appeared to be feces, one jar suspected of containing urine and three bottles of what they think is paint.
"All of these items - as well as significant quantities of feminine hygiene products, glitter and confetti possessed by individuals - were required to be discarded; otherwise those individuals were denied entry into the gallery," the department said in a statement.
The confiscation of feminine hygiene products sparked an outcry on social media about "tampongate".