WASHINGTON — Just days away from a partial government shutdown, lawmakers are weighing adding a contentious measure to a stymied spending package that would keep American companies from participating in boycotts — primarily against Israel — that are being carried out by international organizations.

Critics of the legislation, including the American Civil Liberties Union and a number of Palestinian rights organizations, say the bill infringes on First Amendment rights and is part of a broader effort on the state and federal levels to suppress support for efforts to boycott, divest investments from and place sanctions on Israel, a movement known as B.D.S.

“The crux of it is silencing one side of the Israel-Palestine conflict,” said Manar Waheed, the senior legislative and advocacy counsel for the A.C.L.U. “Anything that creates a penalty for any First Amendment-related activities is an infringement of the First Amendment.”

The bill, known as the Israel Anti-Boycott Act, is one of several pieces of pet legislation that lawmakers are advocating in the final days of the session, hoping to add to a package of seven spending bills that need to pass to keep the government fully funded past Friday. President Trump has said repeatedly that he will not sign any spending bills unless they contain at least $5 billion to begin building a wall on the border with Mexico.

As the package languishes, lawmakers see an opportunity to give their bills life before the current Congress ends this month. Other pieces of legislation that could be added include the so-called Blue Water Bill, which would allow Vietnam-era sailors who say they were exposed to Agent Orange as they served offshore to receive the same health benefits as those who were exposed on land. Other lawmakers are seeking to reauthorize the Violence Against Women Act, which was extended with a brief stopgap spending bill two weeks ago.

But so far, neither the White House nor congressional Democrats have signaled that they are willing to negotiate on wall funding, so none of the bills have a moving vehicle to latch onto.

Senator Richard C. Shelby, Republican of Alabama and chairman of the Senate Appropriations Committee, told reporters that a decision from Mr. Trump over how to handle the shutdown was imminent. But by Monday evening, nothing had emerged.

Mr. Shelby has objected to unrelated bills clinging to his committee’s work, arguing that their inclusion could be another hindrance to final passage. But among lawmakers eager to notch one more legislative victory in a historically unproductive session of Congress, there is still hope that a few more bills could slip through.

“People are looking for whatever vehicle is available that is moving out the door — there isn’t much left,” said Sue Walitsky, a spokeswoman for Senator Benjamin L. Cardin, Democrat of Maryland and a sponsor of the Israel Anti-Boycott Act. “We’re counting down days and hours.”

Supporters of the measure dispute critics who say it would stifle pro-Palestinian activism.

“These kinds of First Amendment issues were not raised in ’77,” said Stuart E. Eizenstat, the chief White House domestic policy adviser during the Carter administration when the amendments were negotiated. “Since it’s come up here, in many ways, this legislation is stronger in protecting First Amendment rights because it explicitly indicates that political views are protected.”

The bill sponsored by Mr. Cardin and Senator Rob Portman, Republican of Ohio, was conceived after the United Nations Human Rights Council announced that it would create a database of companies that have business in the West Bank and the Gaza Strip, whose governance and status have been in dispute since the Six Day War in 1967.

“From our perspective, we have to protect U.S. companies from being put in a position that could harm them,” Ms. Walitsky said.

The bill, which would impose penalties on boycott participants, has already been modified after complaints from the A.C.L.U., which does not publicly take a stance on the Israeli-Palestinian conflict, about the infringement on First Amendment rights. Supporters of the legislation say that the language does not prevent companies and individuals, independent of direction from foreign countries or international agencies, from announcing their intent to boycott Israel.

“Our bipartisan legislation is a direct response to highly selective and discriminatory efforts to isolate Israel, such as those by the U.N. Human Rights Council,” Mr. Portman said in a statement.

But the changes, which most notably reduce the most significant penalty for participation to a fine of up to $1 million, were not seen as sufficient by critics, who scorned efforts to wrap a final version into a spending package without public debate.

If the legislation fails to pass in the final days of this Congress, it will have to be introduced with a Democratic House majority that includes a number of new members who have publicly endorsed efforts to boycott Israel.

“It’s why we live in a democracy,” said Samer Khalaf, the president of the American-Arab Anti-Discrimination Committee. “This sort of sneaky inclusion of it into the omnibus bill, that’s what gives a better chance of it succeeding.”

For Palestinian rights activists, it is also seen as part of a broader national effort to counter their opposition to Israeli policies. More than 20 laws have been passed in states that curb the breadth of efforts to boycott and place sanctions on Israel.

On Monday, Bahia Amawi, a speech pathologist who spent nearly a decade working in elementary schools in a Texas school district, filed a lawsuit, along with the Council on American-Islamic Relations, against a Texas law. She said that her First Amendment rights had been violated after she was required to sign paperwork promising that she “does not” and “will not” engage in a boycott of Israel.

The A.C.L.U. and its Texas branch plan this week to file a separate challenge to the law, on behalf of four Texans who have either lost opportunities because of the certification or felt they lost their First Amendment rights by signing it.

“It’s an attack on my right to protest and my constitutional rights,” Ms. Amawi said. “I’m sure it’s going to be a tough road, but I’m optimistic.”

Correction: Because of an editing error, an earlier version of this article referred imprecisely to the status of Gaza. Israel withdrew from Gaza and does not consider it occupied. Hamas, which governs Gaza, does consider it occupied because Israel still controls most of its borders.