The law would take effect six months after being signed by the governor, but is certain to face legal challenge from the American Civil Liberties Union and other groups who have vowed to sue.
Legislation to restrict abortion rights has been introduced in 16 states this year, four of whose governors have signed bills banning abortion if an embryonic heartbeat can be detected.
The Alabama bill goes further, banning abortions at any time. People who perform abortions would be subject to a felony, punishable by 10 to 99 years in prison, although a woman who receives an abortion would not be held criminally liable.
The Senate also defeated a Democratic amendment that would have allowed legal abortions for women and girls impregnated by rape and incest.
The National Organisation for Women (NOW) denounced the ban as unconstitutional.
"This is a transparent effort to drum up political support for anti-abortion candidates in upcoming elections and serves as a direct threat to women's health, autonomy and pursuit of happiness," NOW said in a statement.
Actress and activist Alyssa Milano has called for a" sex strike" under the social media hashtag #SexStrike in response to the campaigns against abortion rights, urging women to refuse sex with men "until we get bodily autonomy back."
Anti-abortion advocates know any laws they pass are certain to be challenged, and courts this year have blocked a restrictive Kentucky law and another in Iowa law that was passed last year.
But supporters of the Alabama ban said the right to life for the unborn child transcends other rights, an idea they would like tested.
Republican Senator Clyde Chambliss, arguing in favour of the Alabama bill, said the whole point was "so that we can go directly to the Supreme Court to challenge Roe versus Wade."
The high court, now with a majority of conservative justices after Republican President Donald Trump appointed two, could possibly overturn Roe v. Wade, the 1973 landmark decision establishing a woman's right to an abortion.
Just this year, Georgia, Mississippi, Kentucky and Ohio have outlawed abortion after a doctor can detect an embryonic heartbeat.
Opponents call the "heartbeat" legislation a virtual ban because embryonic cardiac activity can be detected as early as six weeks, before a woman may be aware she is pregnant.