Because the number of write-in votes appears to exceed the margin of victory, an Alabama law that requires that the names of write-in candidates be officially tallied is likely to be triggered. Mr. Merrill will determine whether the counting requirement applies by noon on Monday.

Such a count would reveal who, exactly, had snared the votes that might have secured a rare Democratic victory. Past elections have shown a variety of write-in recipients: friends, neighbors, pastors, an imprisoned former governor. Perhaps in that spirit, a liberal “super PAC” sought to starve Mr. Moore of support by promoting Nick Saban, the head football coach at the University of Alabama, as a write-in. (Mr. Saban, who has won four national championships at Alabama and is the state’s highest-paid public employee, has said relatively little over the years about his politics, but he is an especially common write-in. A spokesman said Wednesday that Mr. Saban was not available for comment.)

County-level results suggested that write-in votes hurt Mr. Moore. In two large counties, Madison and Tuscaloosa, write-ins accounted for at least 1.9 percent of the votes cast, ahead of the statewide average. Mr. Jones won both counties, each of which Mr. Trump carried in 2016. In exit polls, demographic groups with the largest proportions of write-in votes included white college graduates (3 percent) and voters aged 18 to 29 (3 percent).

Samuel Moffett, 26, a chemical engineer, called himself “a strong Christian” who used to vote straight Republican. This time, he said, he wrote in the name of Ron Bishop of the Libertarian Party.

Despite Mr. Moore’s strenuous appeals to evangelical Christians, Mr. Moffett said that he found the candidate’s attacks on his female accusers, and his past suggestion that homosexuality should be criminalized, to be disqualifying.

“I don’t think he really acts on the Christian beliefs I want people to associate with my faith,” said Mr. Moffett, who lives in St. Clair County. “He uses his faith as a cop-out.”