DETROIT — President Trump welcomed executives of Harley-Davidson to the White House this week, alongside union representatives, and spent much of a camera spray reminiscing about how union members spurned their leaders to vote for him.

“Sometimes your top people didn’t support me, but the steelworkers supported me, right?” Trump said. “The workers supported us big league.”

Twenty-four hours earlier, at a thinly attended news conference at the other end of Pennsylvania Avenue, Reps. Steve King (R-Iowa) and Joe Wilson (R-S.C.) reintroduced their “right to work” legislation to prevent private-sector unions from compelling members to pay dues. They were joined by Mark Mix of the National Right to Work Committee, which is working toward turning New Hampshire into a “right to work” state.

“During the primary,” Mix said, “President Trump indicated that he would sign a right to work bill if it got to his desk.”

In his first, hectic weeks in power, Trump has tried to capitalize on the support he won from union members with high-profile meetings and some direct actions, like the official end of the Trans-Pacific Partnership and the go-ahead for new natural gas pipelines. Fissures between labor and the Democratic Party, which were papered over as long as they held the White House, have allowed Trump to deliver on promises that set unions against environmental groups and regulators.

But the president’s ambitions are running against the priorities of his party in Congress, and the advisers who have his ear. They may also be undercut by his nomination of Neil Gorsuch for the Supreme Court, an appointment that conservatives say would provide a 5-to-4 winning margin for a lawsuit that would use the First Amendment to end public sector unions’ ability to compel the payment of dues.

“I’m hopeful he does stand in the way, because the Republican are going to come after labor hot and heavy,” said Greg Junemann, president of the International Federation of Professional and Technical Engineers. “His chances of getting reelected are stronger if he does that. Even if it maybe alienates somebody he golfs with.”

As Democrats rebuild their party, the collapse of the labor vote has stood out as 2016’s hardest lesson. Trump won the presidency, in part, because of a surge among voters who belonged to unions — especially white, male union members. In Michigan, where Barack Obama had defeated Mitt Romney in union households by 33 points, Clinton won that group by just 13 points.

Organizers in Michigan, and across the Rust Belt, saw several crises colliding at just the right moment for Trump. The 2016 election was the first since Republicans in Wisconsin and Michigan pushed through right-to-work laws. That not only began to weaken the political power of unions; “save right-to-work” was an argument that fell out of the unions’ persuasion playbook.

And Clinton was a uniquely hard sell for union members. In a speech here, at one of the Democratic National Committee’s “future forums,” United Steelworkers 1999 President Chuck Jones said that he watched members burn with enthusiasm for Sen. Bernie Sanders (I-Vt.), then drop out after the primary.

“Trump was close to getting the majority of our 3,000 members,” said Jones, whose Indianapolis-based union is best known for representing workers at a Carrier plant Trump cut a deal to partially save from outsourcing. “What the hell was Hillary going to argue on? She couldn’t argue anything. Her husband was the one who gave us NAFTA. We had a candidate that we couldn’t get people excited about.”

In conversations this week, labor organizers said Trump could do a few things to build on that support. He could persuade the Republican Congress to pass a free-spending infrastructure bill; he could end the “Cadillac tax” on labor health insurance plans; he could renegotiate or simply abandon the North American Free Trade Agreement; he could continue jawboning companies into keeping business in the United States; and he could continue allowing energy production to increase against the demands of green groups.

“We’ve been talking about changing NAFTA forever, and no one would ever do it,” Teamsters President James Hoffa Jr. said on Fox News last month. “It can be done, and, you know, I applaud the president by having, being so bold to say we’ll just rip it up and negotiate a new one. That’s unheard of. But it really is what needs to be done.”

Trump could, they say, wind all of that with the high-profile personal meetings he’s been holding with union leaders. Two weeks ago, Laborers’ International Union of North America General President Terry O’Sullivan said that the Trump presidency felt like “a new day for the working class,” and the pipeline orders might be just a start to a new Era of Good Feelings.

“President Trump has shown that it is not difficult to put country above politics and create an energy-independent America,” O’Sullivan said. “He has shown that he respects laborers who build our great nation, and that they will be abandoned no more.”

But the rest of the Republican agenda cuts against what the Teamsters, LIUNA and every other union is asking for. O’Sullivan quickly condemned the national “right to work” bill, and other leading unions have warned against Sen. Jeff Flake’s (R-Ariz.) legislation to suspend the Davis-Bacon Act requirements for higher wages on infrastructure projects.

Labor is also girding for a fight that the Trump transition team appears to have manhandled — the nomination of Andy Puzder for labor secretary. The AFL-CIO’s Richard Trumka has teamed up with Senate Democrats to pummel Puzder’s record, portraying him as an icon of worker wage theft, referring to him in a December call with voters as “the classic example of a millionaire CEO who nickels and dimes workers while raking in profits for himself.”

“He has spoken out against increasing the minimum wage,” Trumka said. “He opposes President Obama’s updated overtime rule. He is dismissive of workplace discrimination issues. He appears comfortable reinforcing harmful stereotypes about women, and I could go on.”

Puzder’s nomination hearing has been delayed several times, amid concerns that he might pull out entirely. That’s saved Trump from a fight with organized labor during what is typically a presidential honeymoon period — but it may have also pushed the fight to a time when Democrats are even readier to oppose.

While Congress and the administration present risks for Trump’s outreach strategy, he has succeeded beyond even Democrats’ fears in cleaving law enforcement unions from the broader labor movement. He secured campaign endorsements from the national Fraternal Order of Police, the unions representing Immigration and Customs Enforcement agents as well as Border Patrol agents, a number of local police unions across the country including those in Chicago, Philadelphia, Denver and Cleveland.

Union leaders say their members were impressed by Trump’s law and order rhetoric, his promise to undo Obama cutbacks on their access to military surplus equipment and to pursue legislation to make it a federal crime to kill a police officer, and how accessible and engaging they found his staff — many noting that they still communicate with former campaign manager Corey Lewandowski and White House policy adviser Stephen Miller.

“Unlike some other unions, we don’t just endorse someone just because they have ‘D’ listed after the end of their name,” said Jerry Flynn, the executive director of the New England Police Benevolent Association, which was the first labor union to endorse Trump, throwing their support behind him in December 2015. The 5,000-member law enforcement union representing officers across Massachusetts, New Hampshire, Maine and Vermont sent letters detailing its endorsement process to every candidate in both the Democratic and Republican primaries.

Flynn says they only heard back from two — Jeb Bush, who said he could not make it to their endorsement meetings, and Trump, who said he would be there and who invited the union’s leaders to meet with him in Trump Tower. A half- dozen union leaders traveled to New York City for a two-hour meeting with Trump.

“He didn’t come riding in on a white horse and get the endorsement, Flynn said. “There was some heated discussion.” But the union leadership was swayed, in part, by Trump’s affinity for law enforcement and his promises to oversee a law and order administration. A week after their meeting, Trump traveled to New Hampshire to accept the union’s endorsement.

“For eight long years we’ve been treated as less than desirable by a president who has nothing but hatred for us,” said Flynn, who after the Trump Tower meeting posted on Facebook a picture of him and Trump, both smiling with thumbs up, in front of a wall of Trump’s framed magazine covers and newspaper clippings. “Trump has been a breath of fresh air for us.”

Police union officials in Cleveland describe a similarly involved courtship. First, the union got an email from Robert Paduchik, then Trump’s Ohio campaign manager, asking about the union’s endorsement process. Next, Cleveland Police Patrolmen’s Association President Steve Loomis said several friends invited him to attend an August 2016 Trump rally in nearby Akron, and that when Trump staffers spotted him in uniform, they invited him out to dinner.

“It kind of blossomed from there,” Loomis said. In September, Loomis was among Ohio labor officials who met with Trump and his running mate, then-Indiana Gov. Mike Pence, during a two-hour Labor Day meeting, after which he recommended to his fellow union members that they endorse Trump. After votes of both the union’s board of directors and full 1,300-person membership, the decision was final: They would back Trump.

“Mr. Trump said he was going to be a law and order guy,” Loomis said, describing candidate’s Trump’s three-prong plan. “He said: ‘We’re going to give you the resources that you need. We’re going to give the neighborhoods and the schools the things they need, and I’m going to bring the jobs back.’ ”

While he doesn’t call the White House on every issue, Loomis has made several calls to Trump associates since they took over the White House. Loomis says that one such call happened after a protester spit in the eye of a Cleveland police officer during demonstrations in that city during the inauguration. The union wanted the young man charged, but local prosecutors balked.

“We were getting nowhere up here,” Loomis said. “I made a call and sent video of the incident to my contact up there and got a very positive response.” In addition to the Trump White House, Loomis said he contact local Justice Department officials. Days later, results. “The local prosecutor ended up issuing a felony summons,” Loomis said. “I can’t guarantee to you how it happened, but I know that we reached out and then things started moving.”

Trump’s outreach to building trades has started with the same friendliness — but as the policy challenges have built up, Democrats have fought back. While the much-rumored infrastructure plan has not materialized, Democrats have proposed and unveiled their own $1 trillion plan, promising to create 15 million jobs in a decade. It mirrors what Sanders campaigned on in 2016, which appealed to rank-and-file union members whose leaders could not sell them on Clinton.

“We do it in a way that protects workers’ rights, protects Davis-Bacon, makes sure that the products are American-made, and makes sure that we’re not privatizing our infrastructure,” Sanders said in an interview this week. “Any American, certainly any trade union member will see that what we’re see what we’re doing is far superior.”