Andrew Puzder withdrew from consideration to be labor secretary Wednesday after it became clear that he would struggle to win confirmation amid allegations of wife abuse and employing an illegal immigrant as a maid.

The fast-food company executive’s withdrawal is a major blow to President Trump, who, despite severe opposition from Democrats, had managed to win confirmation of all of his other nominees so far.

“I am withdrawing my nomination for secretary of labor. I’m honored to have been considered and am grateful to all who have supported me,” Mr. Puzder said in a Twitter post.

Previous presidents have had similar hiccups in their early days — President Clinton canceled his first attorney general pick, while several of President Obama’s initial slate of nominees dropped out, including two for the same secretary’s post — yet Mr. Trump’s stumble was being seen as more evidence of instability at the White House.

The next test will come Thursday morning when the Senate is slated to vote on Rep. Mick Mulvaney, Mr. Trump’s nominee to run the White House Office of Management and Budget.

Democrats are stacked against Mr. Mulvaney, and several of his fellow Republicans have been reluctant to commit to him, saying they fear his zeal for budget cuts, particularly when it comes to national defense.

“It would be irresponsible to place the future of the defense budget in [his] hands,” said Sen. John McCain, Arizona Republican and chairman of the Armed Services Committee, who said he would join Democrats in opposition.

Mr. Mulvaney did survive a Democrat-led filibuster attempt Wednesday on a 52-48 vote.

But Mr. Puzder’s withdrawal later in the day put blood in the water, showing more cracks in what had been a fairly united Republican front behind Mr. Trump.

It also served as the first victory for Democrats and the liberal activists who had pushed them to oppose the president’s Cabinet picks up and down the line, as part of a “resist” strategy.

The chief of CKE Restaurants, which runs the Hardee’s and Carl’s Jr. fast-food chains, Mr. Puzder had been under fire from Democrats who said he wouldn’t be an advocate for workers. But it was defections among Republicans, after old accusations of abuse from his ex-wife resurfaced, that sealed his fate.

His confirmation hearings before the Health, Education, Labor and Pensions Committee had repeatedly been delayed, first over paperwork and then as questions mounted. Liberal activists had even gone to court to try to get divorce documents unsealed, and were pushing for more delays on the nomination this week.

Sen. Lamar Alexander, Tennessee Republican and the panel chairman, said Mr. Puzder would have made “an excellent labor secretary, but I respect his decision.”

Puzder spokesman George Thompson told reporters that his boss was sunk by “an unprecedented smear campaign.”

Labor unions cheered the withdrawal, and Mr. Trump will now search for a replacement, though even Democrats said they doubted they would get a candidate more in line with their ideological leanings.

White House spokesman Sean Spicer said Wednesday afternoon that it was too early for him to have information on who might replace Mr. Puzder as the nominee.

Still, toppling Mr. Puzder was vindication for Democrats’ go-slow approach, which forced the Senate to use the maximum amount of time for many of the nominees. Those delays allowed more attention to be paid to individual picks, and the attacks finally began to weigh down Mr. Puzder.

“Workers and families across the country spoke up loud and clear that they want a true champion for all workers in the Labor Department,” said Sen. Patty Murray of Washington, the labor committee’s ranking Democrat.

His opponents criticized everything from his employment practices to racy ads run by one of his fast-food chains, which he defended in Entrepreneur magazine in 2015 by saying, “I like beautiful women eating burgers in bikinis.”

He also admitted to having employed an illegal immigrant as a maid — a charge that has sunk Cabinet nominees for previous presidents.

But his chief hurdle became allegations lodged by his ex-wife, Lisa Fierstein, in a 1980s interview on the “Oprah Winfrey Show” about abuse in her marriage.

Ms. Fierstein withdrew the accusations, but video of the interview made the rounds on television, and the couple’s divorce documents became the latest target for prodding.

The Trump administration had stuck with Mr. Puzder, but a handful of Republicans had withheld their backing, and it was unclear whether he could have survived a committee vote, much less won confirmation on the Senate floor.