The final weeks of Alabama's divisive U.S. Senate campaign have seen multiple churches across the state opening their doors to allow one of the two nominees to speak to their members.

While it's something of a ritual for Alabama politicians to speak at churches during campaigns, experts say such events can run afoul of federal tax law barring churches and other 501(c)3 nonprofits from engaging in too much political activity.

David Thompson, a lawyer who serves as vice president of public policy at the National Council of Nonprofits in Washington, D.C., told AL.com that it is generally fine for pastors to address policy issues from the pulpit, but explicitly endorsing or favoring one candidate over another is a violation of the federal tax code.

"Talking about abortion? No problem. But [they] can do zero politicking in terms of endorsing candidates for public office," he said. "If you have one candidate rally and you're not making your place available for the other side, that's considered endorsement. They're doing everything they can to run right up to the line, and depending on the exact situation, they are crossing the line."

But experts say the IRS has not enforced regulations restricting churches' political activity in over a decade.

"Enforcement is poor. There aren't enough IRS agents on the beat and Congress has tied the hands of the IRS when it comes to what they call a church audit," Thompson said.

Plus, the U.S. may well be seeing the last gasp of IRS restrictions on politicking in churches. The version of the tax overhaul bill that passed the U.S. House of Representatives last month would repeal the Johnson Amendment - the portion of the federal tax code that bars churches and other 501(c)3 nonprofits from engaging in excessive political activity.

As it stands today, if a church avoids endorsing a candidate and invites both nominees to speak and only one accepts the invitation, they likely haven't broken the law, according to Margaret Sessa-Hawkins, a reporter at the Berkley, California-based campaign finance nonprofit MapLight.

Moore's campaign did not respond to multiple inquiries Wednesday. Over the past two weeks, at least three churches allowed Moore to speak to their congregations.

Sebastian Kitchen, a spokesman for the Jones campaign, did not answer specific questions about the fact that he has spoken at multiple churches over the past two months, and instead provided a one-sentence statement via email.

"Doug regularly attends church services, and sometimes is invited by community leaders to say a few words," Kitchen wrote.

U.S. Senate candidate Doug Jones speaks at the Maggie Street Baptist Church in Montgomery on Dec. 1.

Anthony Burke, a spokesman for the Internal Revenue Service, declined to provide comment for this story, but he did send AL.com a link to its "Tax Guide for Churches & Religious Organizations" publication.

The document provides detailed guidance about what types of political activity churches and other 501(c)3 nonprofits can engage in. It states that "they must not participate in, or intervene in, any political campaign on behalf of (or in opposition to) any candidate for public office," and that if they do, they could lose their tax-exempt status.

The guide goes further, specifically stating that nonprofits are barred from making "[c]ontributions to political campaign funds" and making "public statements ... in favor of (or in opposition to) any candidate for public office."

It explains that "[c]ertain activities or expenditures may not be prohibited depending on the facts and circumstances," citing examples of permissible activity including "certain voter education activities" including hosting "public forums" and "voter registration and get-out-the-vote drives."

But experts say the IRS has scant resources for enforcement and that such cases are typically considered political landmines. So though some Alabama churches potentially violated federal tax regulations during this campaign, it is unlikely that they would ever be penalized for their actions. And candidates themselves are not governed by the IRS's nonprofit rules.

"[There have been] no efforts to revoke tax-exempt status for election activity on behalf of a church or other 501(c)3 in at least 10 years, maybe even 20 years," Thompson said.

Congress may soon pull the plug on the Johnson Amendment anyway. Unlike the House bill, the Senate version of the tax overhaul does not contain the provision to repeal the amendment, so it remains to be seen if it will be included in the final version of the law that emerges from joint congressional conference.

"The provision in the House version of the tax bill, not currently in the Senate version, would allow churches to engage in partisan political activity, but it would also allow charities - any entities under section 501(c)3 of the tax code - to engage in politics," said Brendan Fischer, director of the federal and FEC reform program at the Campaign Legal Center, a campaign finance reform nonprofit in Washington.

Some of the churches that have hosted Moore or Jones during this year's Senate campaign told AL.com Wednesday that they did not believe the events ran afoul of any tax laws.

Neither Montgomery's Maggie Street Baptist Church nor Macedonia Baptist Church responded to email and phone inquiries about Jones speaking to their congregations on Dec. 1 and Oct. 20, respectively.

Jeremy Ragland, pastor at Bryan Baptist Church in Dora, spoke with AL.com Wednesday about Moore's appearance at the church on Nov. 30. Moore addressed politically charged topics during his remarks there, including a statement by Jones claiming that Moore's supporters "put down people," which Moore said was untrue.

"If your Christian culture does not accept abortion, same-sex marriage, sodomy, transgender rights in school bathrooms and in the military, then you're discriminatory, and you will not be protected, nor will your right to bear arms be preserved," Moore told the congregation in Dora.

Still, Ragland stated that there "was never intended to be anything political about" the event, which he said was booked months ahead of time.

"I felt like we avoided the political aspect pretty well because that wasn't the intent of the night. If it was up to me we wouldn't have had any media there at all," he said.

"If we broke the rules and [the IRS comes] after us, that's part of it. But I really don't think there was any rules broken. There was no signage up on the property, things like that. I told people who were there that I don't care who you vote for, vote for who you think is best. We have not told people to vote for Roy Moore or Doug Jones or against either one of them."

David Gonnella, pastor at Magnolia Springs Baptist Church in Theodore - where Moore vehemently denied allegations of sexual misconduct during Nov. 29 remarks - said via email Wednesday that "the church does not endorse any political candidate, or any political party," though Gonnella said that he has "personally endorsed" Moore.

"Roy Moore spoke in our regular Wednesday night service. He lectured on bringing Biblical truth to bear on political issues, and did make some references to his campaign, although he did not so much as ask for any votes," Gonnella wrote.

"We did not reach out to Doug Jones for two reasons: [1] We have no prior relationship to him, and are unaware if he is a Baptist like Roy Moore. [2] His views on issues we consider important are not consistent with ours."

Gonnella also responded to questions about whether the church may have run afoul of tax law.

"We know ourselves to be well within the law concerning 501(c)3 organizations," he wrote.

Leria Jordan, a minister at The Guiding Light Church in Irondale, sent AL.com a statement in response to questions about Moore's Dec. 3 appearance at the church.

"Moore visited The Guiding Light Church on Sunday, December 3, 2017 to be a part of our worship service. He requested this opportunity to worship with us and we accepted with the condition that there would be no campaigning. As we do with all candidates who attend our services, we allowed the candidate to say a few words to the congregation during the service," the statement said.

"As it relates to the allegations of Bishop Jim Lowe supporting Senate Candidate Roy Moore, he does not endorse candidates neither does the church."