BIRMINGHAM, Ala. — The word traveled, urgently and insistently, along the informal networks of black friends, black family and black co-workers: Vote.
Joanice Thompson, 68, a retired worker at the University of Alabama at Birmingham, scrolled Tuesday through the text messages on her phone from relatives reminding each other what needed to be done. Byron Perkins, 56, a trial lawyer, said his Facebook feed was clogged with photos of friends sporting the little “I Voted” stickers given out at polling places. Casie Baker, 29, a bank worker, said her family prodded and cajoled and hectored each other until the voting was done.
The message was largely received: African-American voters played an essential role in electing the Democrat, Doug Jones, over his scandal-scarred Republican rival, Roy S. Moore, in a special election on Tuesday for an open Senate seat that proved to be one of the most shocking upsets in recent memory.
They said they were motivated by the specific fears that Mr. Moore would help President Trump cut government aid programs, reduce access to health care and neglect criminal justice reform. But they also voted out of a more general concern that the country, in the Trump era, was going back to a place best left in the past.
“There’s no state in America where black people recognize the horrors of turning back the clock more than the State of Alabama,” said Bryan Stevenson, the founder of the Equal Justice Initiative, which is based in Montgomery. “There is a consciousness about this history in the African-American community.”
In Alabama, he said: “You can’t go two miles without some Confederate emblem or icon or flag taunting you.” He added: “It’s not a fantasy in this state to say we want to turn back the clock.’’
According to CNN exit polling, 30 percent of the electorate was African-American, with 96 percent of them voting for Mr. Jones. (Mr. Jones’s backers had felt he needed to get north of 25 percent to have a shot to win.) A remarkable 98 percent of black women voters supported Mr. Jones. The share of black voters on Tuesday was higher than the share in 2008 and 2012, when Barack Obama was on the ballot.
The effort was nourished by a concerted, well-organized get-out-the-vote effort started by Democrats and their allies that was custom-built for black Alabama voters. One program, a partnership between two national political action committees, boasted that its activists knocked on more than 520,000 doors, with 200,000 knocks coming in the last four days of the race.
They often had to do little by way of convincing. At Mr. Jones’s jubilant victory celebration on Tuesday night, several black voters said they had long harbored a distaste for the fiery brand of evangelical politics that Mr. Moore had relied on to court working-class whites. Devon Crawford, 24, a divinity student at the University of Chicago, said he came home to vote against Mr. Moore.
Mr. Moore’s version of Christianity, he said, “sanctifies the truth-making power of white men” and was “really just a masquerade for white supremacy.”
Many others said that the Jones campaign uncorked the intense feelings of alarm and distaste that many African-Americans harbor toward President Trump, who gave Mr. Moore his full-throated endorsement.
Ms. Thompson, 68, said that she and many of her fellow black voters were worried that Trumpism and a Republican-led Congress would chip away at protections for poor and working-class Americans. “But it’s a matter of character for us, too,” she said.
“Trump has disrespected the United States,” added Walladean Streeter, 68, a retired government worker. “How can you teach children in high school and college to respect their leaders when he’s acting like a child?”
In Alabama, Mr. Stevenson argued, black voters are intimately aware of the state’s civil rights struggles and particularly sensitive to any gestures that might augur a regression. It was the bloody police violence against peaceful protesters in Selma that helped prod Congress to pass the Voting Rights Act of 1965. A crucial part of the act was invalidated by the Supreme Court in 2013, in a case brought by Shelby County, a suburb south of Birmingham.
The voting wars have hardly abated. Many blacks and white liberals continue to harbor suspicions that a 2011 Voter ID law was passed by Republican lawmakers to suppress black votes. And blacks are about three times as likely than others to be denied the right to vote by a state felony disenfranchisement law, said Corey Goldstone, a spokesman for the Campaign Legal Center, a nonpartisan group focusing on election law.
A law passed last year clarified what had been a broad and vague list of the felonies that permanently disqualify people from voting. The Rev. Kenny Glasgow, an activist, has been visiting jails and prisons to register newly eligible voters, most of them black.
There are thousands more eligible to register under the law, most likely a greater number, and possibly far greater number, than the margin of Mr. Jones’ 20,715-vote victory.
Mr. Jones, 63, a former federal prosecutor, entered the race as a not particularly well-known face for many black voters. But he had a deeply resonant story to tell them, having successfully prosecuted two white Klansmen for their roles in the 1963 bombing of the 16th Street Baptist Church in Birmingham that killed four African-American girls.
As Mr. Moore was hobbled by allegations that he had engaged in inappropriate relations with teenage girls while in his 30s, Mr. Jones’s campaign coffers grew fat, and in November his campaign manager said the team would try to make contact — by mail, phone or otherwise — with every likely black voter five or six times before Election Day.
At the same time, national Democrats quietly pumped money into an unannounced independent-expenditure campaign aimed at African-Americans. Senate Majority PAC, the primary “super PAC” for Democratic senatorial candidates, spent $2 million on a grass-roots program aimed at the black vote, strategists said — the same amount of money the group dedicated to television ads. In many cases, it poured money into Alabama-based groups to nourish their efforts.
In addition, about half of the $750,000 the group spent on digital ads, was directed specifically at black voters.
It was the Senate Majority PAC that partnered with a two-year-old group called Black PAC to knock on the 520,000 doors. They were part of a broader coalition of pro-Jones groups that brought their message to Alabama’s African-American voters, from young professionals in cities like Birmingham and Huntsville to those living in the so-called black belt, a rural swath of the state long plagued by poverty where a United Nations official recently visited to call attention to a lack of sewage and other basic services. According to Census figures, blacks lag both Alabama whites, and blacks nationally, in median income and educational attainment.
Democrats were careful to look for ways to reach out to black voters without stirring up white Republicans. Mr. Jones toured black churches in Selma with Representative Terri Sewell, an African-American congresswoman. Other prominent black supporters made appearances on his behalf, including Representative John Lewis of Georgia and Senator Cory Booker of New Jersey.
How the Tide Turned Against Roy Moore in Alabama
Analysis of the U.S. Senate election results, both statewide and broken down by key counties and voter groups.
Toward the end of the campaign, Mr. Obama recorded a robocall for Mr. Jones, and the former basketball star Charles Barkley, an Alabama native, urged voters to reject Mr. Moore at a campaign event on Monday. “We’ve got to, at some point, we got to stop looking like idiots to the nation,” Mr. Barkley said.
A few hours later, in a hotel ballroom, Michael Nabors, 54, and his wife, Ella, 55, were among the black voters soaking up the Democratic good cheer after news agencies called the race for Mr. Jones.
“We knew the world was looking at us,” he said.
Mr. Nabors said that black voters were paying attention to Mr. Moore’s comments in September, in which he said that America was last “great” during the days when slavery was legal. He said they paid attention when Mr. Moore brought Stephen K. Bannon, the former Trump adviser, to campaign for him. He said that they paid attention to the allegations brought by the women who said Mr. Moore had consorted with them when they were young.
And he said they paid attention to Mr. Jones’s most famous case as a prosecutor.
“Those four little girls are on their feet tonight at 16th Street Baptist Church, celebrating,” he said. “They’re celebrating in spirit.”