WASHINGTON — Gov. John Kasich of Ohio on Tuesday signed into law a ban on abortion after 20 weeks of pregnancy, but vetoed a far more restrictive measure that would have barred abortions after a fetal heartbeat was detected, as early as six weeks into a pregnancy.

In reaching the split decision on the two bans, adopted last week by the Ohio legislature, Mr. Kasich said the so-called heartbeat bill was “clearly contrary to the Supreme Court’s current rulings on abortion.” He called the 20-week ban the “best, most legally sound and sustainable approach to protecting the sanctity of human life.”

The 20-week ban has no exceptions for rape or incest, and abortion rights advocates consider it extreme. Under existing Ohio law, there will be an exception for life of the mother, Mr. Kasich’s office said. Current Ohio law bars abortion after 20 weeks unless doctors can show that the baby is not viable outside the womb. Many medical experts cite the age of viability as 24 weeks.

With the governor’s signature, Ohio becomes the 18th state to adopt a 20-week abortion ban, though two of the bans — in Arizona and Idaho — have been struck down as unconstitutional by federal courts. Legal experts say Ohio’s 20-week ban is far more likely to survive a constitutional challenge than the heartbeat bill.