The Senate is expected to pass a $40 billion aid package for Ukraine, sending it to Biden.

The Senate is set on Thursday to give final approval to a $40 billion emergency military and humanitarian aid package for Ukraine, as the United States deepens its support for an increasingly costly and protracted fight against a Russian invasion.

The measure is the largest foreign aid package passed by Congress in at least two decades, and its enactment would bring the American investment in the war to roughly $54 billion in just over two months. The Senate was expected to approve it overwhelmingly, in the latest reflection of the remarkable bipartisan support on Capitol Hill for a massive investment in Ukraine’s war effort, which propelled the spending package through the House last week.

President Biden was expected to quickly sign it into law. His administration and Ukrainian leaders have pressed hard for its swift enactment, warning that they would run out of aid by Thursday if Congress failed to act.

The measure’s relatively smooth path through Congress has demonstrated how the searing images of suffering in Ukraine, coupled with fears about Russian aggression spreading beyond the country’s borders, have — at least for now — overcome resistance from both parties to American involvement in war abroad.

Fewer than a dozen Republicans opposed bringing up the bill in a test vote on Monday; several who did cited concerns about sending billions of dollars abroad for a conflict whose endpoint is unknown at a time when the United States is struggling with economic challenges, including inflation.

Leaders in both parties sought to ensure that skepticism about the scope of the package did not derail its passage. Senator Mitch McConnell, Republican of Kentucky and the minority leader, led a delegation of senators in his party in a surprise visit to Ukraine last weekend and pledged bipartisan support for the country’s fight against Russia.

“I think it’s important for the United States to help, important for the free world to help, important for the Ukrainians to win and hopefully, not many members of my party will choose to politicize this issue,” Mr. McConnell said during a press call on Sunday, speaking from Stockholm.

The legislation is substantially larger than Mr. Biden’s $33 billion request, which came only weeks after Congress had cleared a $13.6 billion aid package for Ukraine, roughly equally divided between military and humanitarian aid. The bill on track to pass on Thursday has a similar split.

It would allow Mr. Biden to authorize the speedy transfer of up to $11 billion of American weapons, equipment and defense supplies to Ukraine, and allocate about $9 billion to replenish that stockpile.

Transfers thus far have included relatively expensive weapons like the 5,500 Javelin anti-tank guided missiles and 1,400 Stinger antiaircraft missiles given to Kyiv, as well as less-costly munitions like the 184,000 155-millimeter shells provided to Ukraine for a protracted artillery battle in Donbas.

The package also includes $8.8 billion for a dedicated fund intended to help Ukraine’s government continue to function, and $4.4 billion for international disaster assistance, part of an effort to stem the disruption to the global food chain as a result of the war. Another $900 million would go to assistance for Ukrainian refugees, including providing trauma and support services, English language training, and housing.

John Ismay contributed reporting.