WASHINGTON >> The collapse of Ukraine aid in Congress was months in the making, and exactly what Senate Republican leader Mitch McConnell had feared.

McConnell had warned that political support for Ukraine was in danger as a small but vocal contingent of fellow Republican lawmakers intensified its efforts against sending U.S. money overseas for the fight against Russia.

First in a series of high-profile speeches this summer then in direct overtures to the White House, the Republican leader who had visited Kyiv and put a priority on U.S. support for Ukraine tried to steer the hard-right flank of his party.

But in the end, neither McConnell nor the White House nor Democrats in Congress could muscle a scaled-back $6 billion military and civilian aid package for Ukraine to passage in last week’s deal to avoid a U.S. government shutdown.

Despite overwhelming bipartisan support in Washington for stopping Russian President Vladimir Putin’s invasion, the failure to approve Ukraine aid was a sizable setback for an administration seeking to lead a Western alliance to protect the young democracy as the fighting grinds on.

It also shows the perils ahead in Washington as a hardened band of Republican lawmakers who are just a minority in Congress — many allied with Donald Trump, the party’s 2024 presidential front-runner — flex their power to overcome the will of the majority. The next steps are highly uncertain.

“It does worry me,” President Joe Biden acknowledged recently. “But I know there are a majority of members in the House and Senate — both parties — who have said that they support funding Ukraine.”

“Not another penny for Ukraine!” wrote Rep. Marjorie Taylor Greene, R-Greene, a top Trump ally, arguing money should be spent on securing the U.S. border with Mexico instead.

McConnell, R-Ky., had been trying to build support Ukraine for months, ever since he met with President Volodymyr Zelenskyy in Kyiv in May.

But after the White House announced Biden’s $24 billion request for Ukraine aid in August, McConnell knew it would not have the support needed to pass, according to a person familiar with the situation and granted anonymity to discuss it.

McConnell had met with a group of Republican defense hawks in the Senate before the end of September deadline to fund the government or risk a shutdown, which would typically be the time to also pass the White House’s spending request for Ukraine.

But the GOP senators left McConnell with the understanding the support for Ukraine funding overall would be lacking.

The White House, in a series of conversations with McConnell’s team over the weekend, considered smaller amounts of funding and insisted that the Ukraine aid was vital.

McConnell agreed to do what he could. Days later, the Senate advanced its package to keep government open for the short term, until Nov 17, with $6 billion for Ukraine. It passed the Senate on an overwhelmingly bipartisan vote.

The problem was, however, that the Democratic leaders on Capitol Hill had never fully articulated Ukraine as a top priority as they fought off House Republican demands for steep budget cuts to keep the government open.

And McCarthy, R-Bakersfield, was having his own problems in the Republican-led House.

Hard-liners in the House had essentially forced McCarthy to strip a much smaller amount of Ukraine security assistance funds, $300 million, from an annual defense funding bill.

It was a stark example of how a growing flank of the party — some 100 Republicans — was wresting control from the majority who widely supported the bill.

It was a sign of the trouble to come.

Staring down a potentially devastating government shutdown, the embattled McCarthy then stripped the $6 billion Ukraine aid from the federal funding package before the House vote to keep the U.S. government open.

As the House was preparing Oct. 7 to avert a shutdown, McConnell convened his Republican senators behind closed doors for a lunch meeting.

McConnell spoke of the need to retain the Ukraine aid in the final package, but it was clear the room was not with him.

South Dakota Sen. John Thune, the Republicans’ second in command, had been in talks with McCarthy, including that morning, and understood from the speaker that the package could not pass with the Ukraine aid attached.

Thune told the Republican senators he thought they should move forward with the House version, without the Ukraine money, as the best way to avoid a shutdown, according to Republican familiar with the private meeting.