Are you there, God? It’s me, a guy who isn’t a senator. Photo: Joe Raedle/Getty Images

Tuesday night was full of surprises. First, Democrat Doug Jones defeated Republican Roy Moore to win the special Senate election in deep-red Alabama. Then, President Trump (or the person who absconded with his phone) responded with this gracious, coherent, and properly punctuated tweet:

Congratulations to Doug Jones on a hard fought victory. The write-in votes played a very big factor, but a win is a win. The people of Alabama are great, and the Republicans will have another shot at this seat in a very short period of time. It never ends! — Donald J. Trump (@realDonaldTrump) December 13, 2017

However, in an entirely unsurprising development, Moore refused to accept defeat, and told supporters that God still isn’t done with the Alabama Senate race. “Realize when the vote is this close that it’s not over,” Moore told his supporters in Montgomery.

He went on to suggest that there would be a recount, adding, “we also know that God is always in control.” After quoting Psalm 40, he said, “That’s what we’ve got to do, is wait on God and let this process play out.” Then he sent his supporters home, explaining he couldn’t have them waiting around all night for the final tally.

"Realize when the vote is this close –– that it's not over." Republican Roy Moore refuses to concede to Democrat Doug Jones, despite losing a close Alabama Senate race. https://t.co/YNIst4Ggn1 pic.twitter.com/dEIMgYiAZ1 — CBS News (@CBSNews) December 13, 2017

In reality, all precincts have reported, and Jones received 49.9 percent of the vote to Moore’s 48.4 percent. Under Alabama law, there’s an automatic recount at the state’s expense if the results are within half a percentage point. But the gap between Jones and Moore is 1.54 percent, or about 20,715 votes.

So what about the “write-in votes” that Trump referenced? It’s true that there were 22,819 write-in votes, which could have given Moore another 1.7 percent of the vote and put him over the top — but only if all of those voters opted to write in Moore’s name, rather than just filling in a circle on the ballot.

Moore’s campaign mentioned that military ballots have yet to be counted, but the Washington Post notes that there are only 8,700 people from Alabama serving in the armed forces. Even if every single one of those troops voted for Moore, he still wouldn’t win.

CNN’s Jake Tapper asked Alabama secretary of State John Merrill if there’s any chance that Jones won’t ultimately win the race. “I would find that highly unlikely to occur,” Merrill said. “There’s not a whole lot of mistakes that are made.

“The people of Alabama have spoken tonight,” Merrill added. “They’ve made their voice heard loud and clear. The most important thing to remember now is the process needs to be followed to ensure that the integrity, the safety, and security of the election is preserved.”

Later in the night, Merrill laid out how the votes are processed in the coming days. He said the vote must be certified between December 26 and no later than January 3.

Merrill suggested on CNN that, after that, Moore could opt to pay for a recount, even if his loss is still greater than half a percentage point. However, Election Law Blog’s Rick Hasen said he thinks that’s incorrect; that law only applies to state offices, not federal elections.

Alabama GOP chair Terry Lathan indicated that the state party is done fighting for Moore, concluding her statement by saying, “Now that this race has ended.”

But that doesn’t mean this is the last we’ve heard of Moore. As Bloomberg’s Noah Feldman notes, he didn’t let being removed from Alabama’s chief justiceship twice dampen his political ambitions. Whether he runs for governor or perhaps takes another stab at being chief justice or senator, he now knows that sizable number of Alabama voters will stick with him even when he’s facing appalling sexual-misconduct allegations.