Just how much Mr. Trump’s backing will help Mr. Van Drew, a former dentist and state legislator, remains to be seen. Several Republican candidates already planning on running for the district’s Republican nomination have warily eyed Mr. Van Drew’s defection while making clear they intend to stay in the race.

But Mr. Van Drew was facing two unappealing options: most likely lose as a Democrat, or roll the dice and see if he could win as a Republican.

Only last month, Mr. Van Drew seemed to regard the Democratic Party as a perfectly good fit; he vowed that he would remain a Democrat even as he continued to oppose impeachment. But that was before he saw the results of a poll of Democratic primary voters that made plain that he was exceedingly vulnerable in his district, with more than 70 percent saying they would be less likely to support him if he voted against impeaching Mr. Trump.

Mr. Van Drew met privately with Mr. Trump in the residence of the White House last Friday, with Mr. Trump’s top adviser, Kellyanne Conway, in attendance, according to two people briefed on the meeting who requested anonymity to discuss internal conversations. Mr. Van Drew sought assurances from the president, and Mr. Trump said he would support him publicly, those briefed said.

Others who were closely involved were Chris Christie, the former New Jersey governor who is a longtime friend of Mr. Trump’s, and who still holds extensive sway with Republicans in the state. Bill Stepien, the White House political director, has deep ties in New Jersey and was intimately involved in the effort. He spent the past 10 days in the southern part of the state to work his contacts to help the move come about, according to two Trump advisers.

Congressional Democrats condemned Mr. Van Drew’s move. Representative Cheri Bustos of Illinois, the chairwoman of the House Democrats’ campaign arm, demanded in a scathing statement that Mr. Van Drew apologize to his constituents for “betraying their trust” in a “misguided attempt to save his own political future.” (Omitted from the statement was that Mr. Van Drew had also betrayed the trust of the campaign arm, which had intervened in his primary to support him when he won the seat last year.)

Representative Bill Pascrell Jr., Democrat of New Jersey, was blunter.

“Do you know what we would have done with a guy like that in my neighborhood in Paterson?” Mr. Pascrell told reporters, adding, “I don’t advocate violence.”