“I think that Senator McConnell understandably did not want to tee up an issue that split our caucus right before the 2016 election,” said Mr. Cornyn, who noted that aspects of the legislation had been misconstrued by its critics.

Presidential politics were at work as well. Mr. Trump has been campaigning on warnings of a United States at risk from sinister forces, even though violent crime is low compared with past decades. But crime surges in some urban areas have given opponents of the legislation ammunition to challenge it.

“I think he’s highlighted some of the crime surges we’ve seen, and I do think it should require proponents of the federal legislation to re-evaluate their position,” said Senator Jeff Sessions, Republican of Alabama, referring to Mr. Trump.

Mr. Sessions is both a chief ally of Mr. Trump on Capitol Hill and a leading opponent of the criminal justice legislation, along with the Republican Senators Tom Cotton of Arkansas and David Perdue of Georgia. Mr. Cotton said this year that the United States suffered from an “under-incarceration” problem, not from too many people being in prison. These critics have been supported by an association of federal prosecutors that has assailed the legislation.

Frustrated supporters of the proposal have pushed back, noting that even if violent crime is rising in some locations, the legislation is aimed at nonviolent criminals, mainly drug offenders. But the clash created a political dissonance and made some Republicans reluctant to risk their tough-on-crime image immediately before an election.

Democrats and progressive groups have been leery of an insistence by conservatives that any final legislation include a provision that could make it more difficult to prosecute white-collar crimes. Passage of a separate measure addressing the opioid crisis gave lawmakers an accomplishment to tout on the drug issue.