Mayor Eric Adams of New York City has quietly explored running in this spring’s Republican primary as he searches for a path to a second term, according to one Republican official and two people familiar with his deliberations.

The mayor, a Democrat, had privately weighed for weeks whether to change his party affiliation or seek a waiver to run in both the Democratic and Republican primaries. But conversations ramped up around the time President Trump’s Justice Department ordered prosecutors to drop corruption charges against him.

Mr. Adams spoke about his political options by phone on Monday with Mike Rendino, the Bronx Republican Party chairman, Mr. Rendino said. The mayor separately connected with Andrea Catsimatidis, the chairwoman of the Manhattan Republican Party, though it was unclear if the race was discussed, according to one of the people familiar with the deliberations.

“He just wanted to speak about pleasantries,” Mr. Rendino said in an interview. “I said let’s not beat around the bush, you’re obviously calling for more than that.”

When the mayor pressed him on the process to run in the Republican primary, Mr. Rendino said, he laid out two potential paths. Mr. Adams could join the party, the chairman told him. Or he could seek a waiver, known as a Wilson Pakula certificate, from Republican county leaders to run on their ballot line without changing parties.

“He didn’t say one way or another what he wanted to do,” Mr. Rendino said.

Asked about the conversations on Wednesday, Mr. Adams’s team reaffirmed that he planned to run as a Democrat, not a Republican, and would soon begin collecting signatures necessary to get on the ballot.

“I am not running as a Republican,” the mayor said in a written statement.

People close to Mr. Adams said that the situation was evolving quickly and that the mayor had been exploring a wide array of options, from running as an independent to trying to compete on multiple party lines at once.

But even initiating the discussions, which have not been previously reported, underscored just how precarious his political position has become a little more than four months before Primary Day.

Mr. Adams is up against a series of tight deadlines. New Yorkers, including the mayor, have until Friday to change party affiliation. And both Republican and Democratic candidates are already competing for endorsements to try to deprive him of another term in City Hall.

It is unclear whether Mr. Trump or members of his administration played any role in the discussions about the mayor’s political future.

Mr. Adams, a onetime Republican who was elected as a centrist Democrat, has assiduously courted Mr. Trump in the months since his indictment last September, visiting the president at his Florida golf club, attending his inauguration and publicly vowing not to criticize him.

The monthslong dance appeared to pay off for Mr. Adams on Monday, when the Justice Department, now under Mr. Trump’s control, said it would seek to have five federal criminal counts dropped against the mayor.

In many ways, Mr. Adams’s interest in running in the Republican primary could be a plausible next step.

“People often say, ‘You don’t sound like a Democrat. You seem to have left the party,’” Mr. Adams said in a recent interview with Tucker Carlson, the former Fox News personality. “No, the party left me, and it left working-class people.”

A bevy of recent polls have all painted a dire picture for Mr. Adams’s standing with the city’s large Democratic voter base. A large majority of New Yorkers disapprove of the job he is doing as mayor, and the surveys have all shown that he is struggling to attract more than 10 percent of the Democratic primary vote.

The intervention by the Justice Department on Monday may have made Mr. Adams’s path to winning back Democratic support more arduous. His rivals and even stalwart allies have argued that the department’s decision — which it said would free Mr. Adams to help enforce Mr. Trump’s immigration policies and which allows prosecutors to revisit the case after the November election — effectively gave the president dangerous influence over City Hall.

Switching political parties and running on multiple ballot lines are not unheard-of in New York politics. The most prominent recent example was Mayor Michael R. Bloomberg, who successfully ran for re-election as an independent in 2009 but won a Wilson Pakula certificate to simultaneously compete on the Republican line.

Mr. Adams himself was registered as a Republican in the 1990s.

It is not clear that a Republican primary would be any easier for Mr. Adams to win than a Democratic one. Despite his overtures to Mr. Trump, many of the mayor’s policies have been unpopular with New York City Republican voters and their representatives.

The mayor, who is strapped for campaign funds, would also still have to collect thousands of signatures from registered Republican voters to get on the primary ballot. And even if he won the Republican primary, he could face a difficult path in November in a city where Democrats vastly outnumber Republicans.

Many prominent Republicans appear to be outright opposed to the idea.

“I only speak as one Republican elected official in this city, but I don’t see that happening because the mayor is not in line with our policies,” said Representative Nicole Malliotakis, the city’s only Republican member of Congress.

Mr. Rendino, the Bronx chairman, said his borough would be similarly skeptical.

“Would they welcome him? No, it would be a very tough sell,” he said. “How is he going to explain the 2,200-person, all-male migrant shelter he’s shoving down our throats in the Bronx?”

Republicans have begun coalescing around a candidate, Curtis Sliwa, the well-known founder of the Guardian Angels who ran against Mr. Adams in the 2021 general election. Mr. Sliwa has already secured the backing of the Staten Island and Brooklyn Republican parties.

But privately, party leaders said they were still waiting to see if Mr. Trump might intercede on Mr. Adams’s behalf. Even Mr. Sliwa said in an interview that the president could have considerable sway.

“The whole notion here is that the president or one of the president’s men or women can call up the county chairmen and tell them, ‘I want you to support Adams and give him a Wilson Pakula,’” he said. “Obviously, they all would do it, they’re not going to say no.”

To win a Wilson Pakula certificate, Mr. Adams would most likely need the support of at least three of the five borough party chairs, or a majority of party’s committee members in New York City.

Richard Barsamian, the Brooklyn Republican chairman, said he “had absolutely no conversations of any kind with Mayor Adams.”

Tony Nunziato, the chairman of the Queens Republicans, said he had not heard from the mayor, either.

Mr. Sliwa, who hosts a radio show on Mr. Catsimatidis’s radio station, said he was still concerned.

“All the insiders they talk to me,” he said. “They say, ‘You know, this is a very real possibility.’”

Dana Rubinstein, Michael Rothfeld and William K. Rashbaum contributed reporting.