The House voted Monday to reject President Trump’s veto of a $741 billion defense authorization bill, setting up the first congressional override of his presidency just days before he exits office.

The 322-to-87 vote was comfortably more than the two-thirds of the House that was needed to pass the measure and set up the legislation for a similar override vote in the Senate later this week. But the House’s margin of victory was smaller than the support the same bill received earlier this month, before the president’s veto. Some Republicans who supported the measure three weeks ago did not vote to override the president’s veto.

Trump made good on repeated threats to veto the legislation last week, when he sent the bill back to Congress with a laundry list of objections. Among the president’s complaints were that it ordered the Pentagon to change the names of military installations commemorating Confederate generals; restricted his ability to pull U.S. troops out of Germany, South Korea and Afghanistan; and did not repeal an unrelated law giving certain liability protections to technology companies.

His move led some of his stalwart supporters, including House Minority Leader Kevin McCarthy (R-Calif.), to announce that they would not cross the president’s veto, even though they had voted for the defense bill. But despite those gestures of solidarity, the president never had the numbers to sustain a veto, according to congressional officials.

In a statement after the vote, House Speaker Nancy Pelosi (D-Calif.) called on Trump to “end his eleventh-hour campaign of chaos,” and respect the will of Congress.

Trump should “stop using his final moments in office to obstruct bipartisan and bicameral action to protect our military and defend our security,” she said.

Since the summer, the National Defense Authorization Act — an annual measure authorizing funds for everything from overseas military operations to pay increases for service members — has had overwhelming, veto-proof support in both chambers of Congress and the backing of a majority of each political party.

Over several weeks, many leading Republicans, particularly in the Senate, engaged in a concerted effort to get Trump to back off his veto threat, arguing that if the president’s push to retain the Confederate names kept the defense bill — for the first time in six decades — from becoming law, he would be on the wrong side of history.

They also appealed to Trump to abandon his insistence that the bill repeal Section 230 of the Communications Decency Act, a law that shields social media companies from legal liability for what third parties post to their websites. Trump has taken special aim at the law as part of his vendetta against Facebook, Google and Twitter for what he alleges is anti-conservative bias.

On Sunday night, Trump included a mention of Section 230 in a statement announcing he had signed a federal budget and pandemic relief bill into law.

“Congress has promised that Section 230, which so unfairly benefits Big Tech at the expense of the American people, will be reviewed and either be terminated or substantially reformed,” Trump said.

Trump’s statement did not represent a concession from Congress but a reflection of reality. While Democrats and most Republicans are in agreement that Section 230 needs revisiting, they also believe that it should be changed through a more careful process rather than shoehorning it into the defense bill.

Some leaders hoped that Trump’s statement could free some Republicans who were loath to cross his veto over the Section 230 issue to support Monday’s override vote in the House.

Speaking on the floor just before the vote, the House Armed Services Committee’s top Republican, Rep. Mac Thornberry (Tex.), implored his colleagues to do so.

“It’s the exact same bill. Not a comma has changed,” he said, calling on those who had backed the legislation earlier this month to vote in support of it again.

The panel’s chairman, Rep. Adam Smith (D-Wash.), said the defense bill presented Congress with a rare opportunity to close the year on a high note.

“We put together a bipartisan, bicameral product that has gotten an overwhelming number of votes,” Smith said. “Let’s show the American people that the legislative process works, at least a little better than sometimes they think it does.”

The bill now heads to the Senate, which must also pass the measure with a two-thirds majority for it to become law. That vote could happen as soon as Wednesday.

Congress to date has never been able to muster the votes to override any of Trump’s vetoes, of which there have been nine since the start of his presidency. That is a higher rate of vetoes than either Barack Obama or George W. Bush, who each issued 12 vetoes over eight years in office. Before them, Bill Clinton issued 36 vetoes and George H.W. Bush issued 29. Each of those presidents faced at least one veto override by Congress.

Parts of the bill run against key elements of Trump’s agenda. The bill’s provisions restricting troop reductions at foreign outposts were inspired by Trump’s efforts to do so over the objections of Congress. Similarly, its prohibition on presidents using their emergency authority to move unlimited military construction funds to pay for domestic projects is a response to Trump’s efforts to siphon off billions of dollars in military funds to pay for a border wall.