Gov. Dave Heineman of Nebraska signed a law on Tuesday banning most abortions 20 weeks after conception or later on the theory that a fetus, by that stage in pregnancy, has the capacity to feel pain. The law, which appears nearly certain to set off legal and scientific debates, is the first in the nation to restrict abortions on the basis of fetal pain.

Abortion opponents praised the law and said it was justified by medical evidence gained since Roe v. Wade was decided in 1973. Abortion rights advocates said that the measure was unconstitutional, and that the motive behind it was to set off a challenge to legalized abortion before the United States Supreme Court.

The Nebraska law grew out of a battle over abortion waged in a far different forum. After an abortion opponent killed Dr. George R. Tiller, a leading late-term abortion provider in Wichita, Kan., last year, Dr. LeRoy H. Carhart, who sometimes worked with Dr. Tiller, said he would carry on his legacy by performing some later-term abortions in his clinic in Bellevue, Neb.

Lawmakers in Nebraska were outraged at the prospect of becoming, in the words of one of the state’s leading anti-abortion groups, the next “late-term abortion capital of the Midwest.” Early Tuesday, the state’s nonpartisan unicameral legislature passed the new measure overwhelmingly, 44 to 5.