Speaker Paul D. Ryan’s abrupt decision to dismiss the House chaplain triggered an uproar on Friday over religion, pitting Republican against Republican and offering Democrats a political opportunity in a year already moving their way.

Mr. Ryan moved quietly two weeks ago to remove the chaplain, the Rev. Patrick J. Conroy — so quietly that some lawmakers assumed the Catholic priest was retiring. But in an interview on Thursday with The New York Times, Father Conroy said he was blindsided when Mr. Ryan asked him to resign, and suggested politics — specifically a prayer he gave in November when Congress was debating a tax overhaul — may have been a factor in the speaker’s decision.

Father Conroy prayed then for lawmakers to “guarantee that there are not winners and losers under new tax laws, but benefits balanced and shared by all Americans.” Shortly after, he said, he was admonished by Mr. Ryan of Wisconsin, who is also a Roman Catholic.

“Padre, you just got to stay out of politics,” he recalled the speaker saying.

As reports of the dismissal circulated in the Capitol, some Republicans, in a closed-door meeting on Friday morning, demanded an explanation from Mr. Ryan, while Democrats commandeered the House floor in a boisterous, if unsuccessful, attempt to force the House to investigate Mr. Ryan’s decision.