WASHINGTON >> The Internal Revenue Service said churches and other houses of worship can endorse political candidates to their congregations, carving out an exemption in a decades-old ban on political activity by tax-exempt nonprofits.

The agency made that statement Monday in a court filing intended to settle a lawsuit filed by two Texas churches and an association of Christian broadcasters.

The plaintiffs that sued the IRS had previously asked a federal court in Texas to create an even broader exemption — to rule that all nonprofits, religious and secular, were free to endorse candidates to their members. That would have erased a bedrock idea of American nonprofit law: that tax-exempt groups cannot be used as tools of any campaign.

Instead, the IRS agreed to a narrower carveout — one that experts in nonprofit law said might sharply increase politicking in churches, even though it mainly seemed to formalize what already seemed to be the agency’s unspoken policy.

The agency said that if a house of worship endorsed a candidate to its congregants, the IRS would view that not as campaigning but as a private matter, like “a family discussion concerning candidates.”

“Thus, communications from a house of worship to its congregation in connection with religious services through its usual channels of communication on matters of faith do not run afoul of the Johnson Amendment as properly interpreted,” the agency said, in a motion filed jointly with the plaintiffs.

The ban on campaigning by nonprofits is named after former President Lyndon B. Johnson, who introduced it as a senator in 1954. President Donald Trump has repeatedly called for its repeal.

In the filing, the IRS and the plaintiffs asked a federal judge to enter an order barring the Trump administration — and any that came after it — from enforcing the ban against the groups that sued.

The IRS did not respond to a request for comment Monday evening. A lawyer for the plaintiffs declined to comment.

The National Council of Nonprofits, which represents 30,000 such groups, warned that allowing tax-exempt groups to endorse candidates could lead to a future where political groups use nonprofits as a kind of legal disguise.

Diane Yentel, the group’s president, said in a statement Monday that the IRS’s move was “not about religion or free speech, but about radically altering campaign finance laws. The decree could open the floodgates for political operatives to funnel money to their preferred candidates while receiving generous tax breaks at the expense of taxpayers who may not share those views.”

For years, the IRS has seemed deeply leery of punishing religious leaders for political statements made during worship. But the experts said this was the first time that the agency had formally said such statements were not just tolerated but explicitly legal.