WASHINGTON — The House voted on Tuesday to overturn President Trump’s declaration of a national emergency on the Mexican border, with just 13 Republicans joining Democrats to try to block his effort to divert funding to a border wall without congressional approval.

House Republican leaders kept defections low after feverishly working to assuage concerns among rank-and-file members about protecting congressional powers and about the precedent that Mr. Trump could be setting for Democratic presidents to use for their own purposes.

“Is your oath of office to Donald Trump or is it to the Constitution of the United States?” Speaker Nancy Pelosi asked her Republican colleagues in a speech on the floor ahead of the vote. “You cannot let him undermine your pledge to the Constitution.”

The resolution of disapproval, which passed 245 to 182, must now be taken up by the Senate, where three Republicans have already declared their support, only one short of the number needed for Congress to ratify a stinging rebuke of Mr. Trump’s efforts.