“It provides Israel with the aid it needs to defend itself, free its hostages and eradicate Hamas, which is a mission that must be accomplished,” Mr. Johnson said at a news conference. “All of this while we also work to ensure responsible spending and reduce the size of the federal government to pay for that commitment to our friend and ally.”

His bill posed a dilemma for many pro-Israel Democrats, who were eager to support the Jewish state at a time of crisis but reluctant to embrace a bill that omits help for Ukraine and humanitarian aid and takes aim at their domestic policy priorities. Leading Democrats including Representative Hakeem Jeffries of New York, the minority leader, made the case privately on Thursday for Democrats to oppose the bill, as did several top administration officials.

Representative Lois Frankel of Florida, one of the 12 Democrats who supported the bill, said in a statement following the vote that she wanted to “send an unequivocal message to the world that we stand with Israel.”

“The United States has a moral duty and national security urgency to aid Israel in defending herself,” Ms. Frankel said. “Make no mistake, Hamas terrorists and others in the region are out to destroy Israel and kill all Jews.”

But in the end, many pro-Israel Democrats opposed the legislation, saying it was unacceptable for Congress to put such conditions on emergency aid for a cherished ally.

“In my worst nightmares, I never thought I would be asked to vote for a bill cynically conditioning aid to Israel on ceding to the partisan demands of one party,” Representative Brad Schneider of Illinois said. “I also never thought that a day would come that I would be asked to consider voting against an aid package for Israel, our most important ally in the Middle East, and maybe in the world.”

But he said he could not back the Republican-written bill, calling it “terribly flawed, weak and dangerous.”

The bulk of the money in the G.O.P. measure would go toward helping Israel replenish and bulk up its weapons systems, including $4 billion for the Iron Dome and David’s Sling missile defense systems. It also includes $200 million for the protection of U.S. personnel and evacuation of U.S. citizens. It leaves out humanitarian aid for Gaza, which Mr. Biden has requested and many Democrats regard as crucial.

Mr. Johnson said he did not attach the spending cuts “for political purposes,” but because House Republicans were “trying to get back to the principle of fiscal responsibility.”

But the nonpartisan Congressional Budget Office said on Wednesday that the spending cuts laid out in the bill would actually increase the deficit by $12.5 billion over the next decade, because cutting back on I.R.S. enforcement would reduce revenue collections. In total, the funding and cuts in the bill would add $26.8 billion to the deficit.

Mr. Johnson appeared to have tailored the Israel legislation to keep his conference, which is deeply divided over funding foreign wars, united in the early days of his speakership. His predecessor, former Speaker Kevin McCarthy, was ousted after he passed two bills — one to avert the nation’s first default on its debt and the other to avert a shutdown — that did not have majority backing from his House Republicans.