WASHINGTON — California Democrat Barbara Boxer capped her 24-year Senate career with a blistering filibuster Friday against what she called a “sneak attack” by her colleague Dianne Feinstein and House Majority Leader Kevin McCarthy against the Endangered Species Act that would devastate the state’s native salmon.

Displaying the verbal fire for which she’s famous, Boxer said Feinstein, D-Calif., and McCarthy, R-Bakersfield, were attempting the very thing that leads the public to despise Congress by dropping a “midnight rider” into a popular water infrastructure bill — that Boxer co-authored — to help a special interest, in this case agribusiness in the San Joaquin Valley.

Avoiding calling out Feinstein by name, Boxer called the rider a case “where people have the power and the money and the ear of a senator” to gain special aid. But it was clear that the sharp criticisms were directed at Feinstein, Boxer’s colleague during her entire Senate career.

But Boxer came up short of the 41 votes she needed to block the $11 billion Water Infrastructure Improvements Act, which authorizes water projects throughout the nation. The Senate passed the bill 69-30 late Friday night. Having already cleared the House on Thursday, the bill and its rider appeared headed to enactment, as White House spokesman Eric Schultz declined to issue a veto threat when asked Friday.

Before the vote, Feinstein defended her bill on the floor and expressed regret for missing a farewell speech Boxer delivered to the Senate on Wednesday, noting that she and Boxer had arrived in the Senate together. “No one has fought for California or for this country harder” than Boxer, she said.

But Feinstein’s absence Wednesday was glaring, coming two days after Boxer publicly tore into the rider’s addition to the water reauthorization bill. Its 98 pages of dense, technical text directs water managers to pump maximum amounts of water from California’s rivers to meet agricultural needs. It says that such pumping should remain within the confines of the Endangered Species Act, but its specific directions override the scientific opinions that govern pumping to protect the rivers’ delicate ecosystems.

The rider also would allow the incoming Trump administration to move ahead on dam building throughout the West without authorization from Congress. .

Turning her anger on McCarthy on Friday, Boxer said she could not leave the Senate peacefully because, “I’m alive and I know what’s going on and I’m going to tell the truth,” she said. “The truth is that Kevin McCarthy is trying to get more water for big agribusiness.”

The Feinstein-McCarthy move represented a bold encroachment on Boxer’s legislative turf. Boxer is retiring this year and had hoped the larger water bill would be the capstone of her career. As the top Democrat on the Environment and Public Works Committee, Boxer worked with committee Chairman James Inhofe, R-Okla., to authorize water projects across the country. These and a provision to fix lead poisoning in the water system of Flint, Mich., made the bill impossible for several Democrats to block and thus vulnerable to a last-minute rider.

Boxer included dozens of projects for California: Wetlands restoration for San Francisco Bay, pollution controls for Lake Tahoe, and levee rebuilding for Sacramento, as well as a big update for the state’s plumbing, with modernized dam operations and investment in desalination, water recycling and other measures to increase water supplies.

Feinstein had argued that her rider contained many of these projects, totaling more than half a billion dollars for California, but Boxer said those were already in the broader water bill.

Feinstein insisted the rider does not violate the Endangered Species Act. Yet the text explicitly mandates pumping beyond what is currently allowed under the act’s biological opinions. The rider also reverses current practices by mandating maximum pumping unless water managers can demonstrate that the pumping harms fish.

As Boxer put it, “by the time they do the report, there will be a lot of dead fish, or no fish.” At least half a dozen native California fish are on the edge of extinction, largely because the state’s rivers are so over-tapped. Farm groups estimate the rider will send as much as 400,000 acre feet of additional water to growers.

Senators representing Washington and Oregon, alarmed by the rider’s effect on salmon in their states, joined Boxer. Sen. Jeff Merkeley, D-Ore., read the text aloud, calling it “a full-fledged bulldozer” running over the Endangered Species Act.

Feinstein had been negotiating with House Republicans for years on a federal response to California’s five-year drought. The rider incorporated elements of a bill Feinstein introduced earlier this year, but the rider itself was negotiated behind closed doors with Republicans and was not subject to hearings.

Feinstein has argued that it would be better to compromise with Republicans on water now, before the GOP is able to pass much worse legislation without fear of veto from the Trump administration.

Boxer predicted the rider instead will provide a blueprint for further dismantling of environmental laws. She said the rider is “not a California drought bill, it’s a how to kill the salmon fishery on the West Coast bill.”

Carolyn Lochhead is the San Francisco Chronicle’s Washington correspondent. Email: clochhead@sfchronicle.com Twitter: @carolynlochhead