Senate Republicans and Democrats on Sunday unveiled a $118.3 billion compromise bill to crack down on unlawful migration across the U.S. border with Mexico and speed critical security aid to Ukraine, but the deal faces long odds in a Congress deeply divided over both issues.

The release of the agreement, struck after more than three months of near-daily talks among senators and Biden administration officials, counted as an improbable breakthrough on a policy matter that has bedeviled presidents of both parties and defied decades of efforts at compromise on Capitol Hill. President Biden, who last month promised he would shut down the border immediately if the measure became law, implored Congress on Sunday to pass the bill and send it to his desk as soon as possible.

“If you believe, as I do, that we must secure the border now, doing nothing is not an option,” he said in a statement, adding that Republicans “have to decide. Do they want to solve the problem? Or do they want to keep playing politics with the border?”

The bill features some of the most significant border security restrictions Congress has contemplated in years. They include making it more difficult to claim asylum, vastly expanding detention capacity and effectively shutting down the border to new entrants if more than an average of 5,000 migrants per day try to cross over unlawfully in the course of a week, or more than 8,500 attempt to cross in any given day.

But Speaker Mike Johnson has already pronounced the bill “dead on arrival” in the Republican-controlled House. And with former President Donald J. Trump actively campaigning against the deal, it was not clear whether the measure could even make it out of the Democratic-led Senate, where it needs bipartisan backing to move forward.

Senator Chuck Schumer, Democrat of New York and the majority leader, said he planned to put the package to an initial vote on Wednesday, in a critical test of its ability to survive.

“I know the overwhelming majority of senators want to get this done, and it will take bipartisan cooperation to move quickly,” Mr. Schumer said in a statement on Sunday.

Yet Senator Mitch McConnell, Republican of Kentucky and the minority leader, stopped short of ordering G.O.P. colleagues to back the bill on Sunday, even as he hailed the measure for including “direct and immediate solutions to the crisis at our southern border.”

The measure includes $20.2 billion to pay for improvements to border security, including hiring new asylum officers and border security agents, expanding the number of available detention beds and increasing screenings for fentanyl and other illicit drugs. It also includes $60.1 billion for Ukraine, $14.1 billion in security assistance for Israel and $10 billion in humanitarian aid for civilians in conflict zones including Gaza, the West Bank and Ukraine.

But the bill falls short of several Republican demands, including ramping up border wall construction and limiting parole and related programs that allow migrants to live and work legally in the United States without visas while they await hearings on their immigration claims — sometimes for years.

Those omissions have alienated right-wing Republicans who insisted on far more severe measures, while the restrictions have enraged progressive Democrats.

“Hard no,” Senator Josh Hawley, Republican of Missouri, said on social media on Sunday, adding in a second post, “This is an open-borders bill if I’ve ever seen one.”

Some immigration proponents also blasted the bill as too restrictive.

“This border deal misses the mark,” Senator Alex Padilla, Democrat of California, said in a statement. “The deal includes a new version of a failed Trump-era immigration policy that will cause more chaos at the border, not less.”

That opposition could complicate the plan’s path through the closely divided Senate, where it needs bipartisan support — at least 60 votes — to move forward. And the compromises threaten to kill the agreement altogether in the G.O.P.-led House, where there is deep opposition to providing additional aid to Ukraine and many right-wing Republicans regard the immigration restrictions as insufficiently tough.

Mr. Johnson and other House Republicans have said repeatedly that they will accept a border deal only if it includes, or at least substantially mirrors, a severely restrictive bill they passed last spring. That legislation would revive a series of Trump-era policies, including a requirement that migrants who cannot fit in detention centers in the United States await their immigration court dates in Mexico.

Mr. Johnson, who has openly resisted putting the Senate deal to a vote, plans to have the House vote instead this week on a measure to send $17.6 billion in security aid to Israel alone and impeach Alejandro N. Mayorkas, the homeland security secretary, on charges that he willfully failed to secure the border.

The bipartisan Senate negotiations were spurred by an ultimatum in the fall by Republicans, who threatened to withhold their support for any bill to send Ukraine a fresh infusion of U.S. assistance unless the money was paired with severe border enforcement measures.

The Senate G.O.P. followed through on the threat in December, blocking an emergency national security spending package requested by Mr. Biden that contained tens of billions in aid to Ukraine, funding for Israel’s war effort in Gaza, humanitarian assistance for Palestinians and security measures to counter Chinese influence in the Indo-Pacific region.

Mr. Biden had included $13.6 billion for border security in his request, an early indication that he and Democrats in Congress saw the situation at the border as a potential political liability in an election year. In the weeks that followed, their willingness to negotiate with Republicans about major policy changes to clamp down on unauthorized border crossings reflected a growing sense in the party of an untenable status quo, with a record-setting influx of migrants arriving in the United States without visas.

Right-wing Republicans have rushed to capitalize on public dissatisfaction with Mr. Biden’s handling of the border, and many have argued that they should not support any immigration legislation that could allow the president or Democrats to claim credit for addressing the issue.

The president’s parole power emerged as a central sticking point in negotiations. Republicans clamored for hard caps on how many people could be let into the United States on humanitarian grounds, as well as an end to most programs allowing people fleeing war-torn and economically ravaged countries to live and work in the United States temporarily.

The bill preserves the president’s parole authority, and does not count people entering under group-based programs or unaccompanied minors toward the threshold of daily migrant encounters that would trigger a border shutdown.

The deal’s authors insist that its new restrictions would still significantly reduce border crossings.

“If this law were already in effect, the border would have been closed every single day this year,” Senator Kyrsten Sinema, independent of Arizona who was one of the main senators negotiating the deal, told reporters.

Encounters would have to fall to an average of 75 percent of the shutdown thresholds for a week before affected processes could be restarted. The bill would also give the president discretionary authority to shut down the border if encounters rose above an average of 4,000 encounters per day in a week.

Republicans have also taken aim at some of the provisions of the compromise that would streamline the asylum process.

The bill would raise the bar for migrants claiming a “credible fear” of persecution if returned to their home countries and would create a new voluntary repatriation program for the government to fly migrants back home on commercial airlines. But it would also direct that migrants with a reasonable fear of persecution be released to live and work in the country, and allow immigration officers to grant asylum status on the spot to migrants presenting especially compelling cases. The bill would also create a review board to hear any appeals of the decisions instead of sending such cases to the courts, with the goal of making final asylum determinations within six months.

The bill includes a measure to provide a government-funded lawyer to any unaccompanied children age 13 or younger, and give any migrant put into expedited removal proceedings 72 hours to find a lawyer to contest deportation.

To relieve backlogs, the bill would also create 50,000 new green-card-eligible visas per year, for five years, 32,000 of which would be for families and 18,000 of which would be employment-based visas. It would also ensure that the children of H-1B visa holders do not lose their green card eligibility once they become adults, and create a new temporary visa category to let noncitizens visit U.S.-based family.

And the measure incorporates a version of the Afghan Adjustment Act, which creates a pathway to citizenship for Afghans who fled to the United States after the Taliban takeover.

Further complicating the bill’s path, several left-wing Democratic senators have expressed uneasiness with the idea of sending military aid to Israel without certain conditions attached. They have called for votes on amendments stipulating that weapons be used in keeping with international law, that humanitarian aid not be hindered and that Congress retain the power to scrutinize any supplies sent to Israel.

Those sentiments could be further inflamed by a provision in the bill that prohibits any of the humanitarian aid from being distributed through the United Nations Relief and Works Agency. The United States and other countries suspended funding to the agency after Israel accused a dozen of its employees of participating in the Oct. 7 Hamas attack.

Hamed Aleaziz contributed reporting.