Dan Janison Melville. N.Y. Tuesday January 26, 2010. Daniel Janison,

Dan Janison has been a reporter at Newsday since 1997.

As if by magic, FBI Director James Comey has morphed from the top lawman vilified by Republicans and hailed by Democrats into the top lawman blasted by Democrats and defended by Republicans.

And it all happened within four months.

When Comey declined in July to prosecute Hillary Clinton over mishandling State Department emails, GOP candidate Donald Trump tweeted: “The system is rigged. . . . Very very unfair!”

At the time, Clinton ally Donna Brazile sent this message: “Simply pathetic to watch [GOP] members of Congress grill Director Comey because he’s not playing their game of gotcha.”

The script changed on Friday.

Eleven days before the election, Comey informed Congress the bureau is reviewing emails turned up in its sexting probe of Anthony Weiner, estranged husband of top Clinton aide Huma Abedin.

“We don’t ordinarily tell Congress about ongoing investigations,” Comey said, “but here I feel I also think it would be misleading to the American people were we not to supplement the record” of the Clinton case. But, he said, “We don’t know the significance of this newly discovered collection of emails.”

advertisement | advertise on newsday

Departing Senate Minority Leader Harry Reid (D-Nev.) angrily suggested Comey had crossed a legal and political line.

Reid wrote: “It has become clear that you possess explosive information about close ties and coordination between Donald Trump, his top advisers and the Russian government — a foreign interest openly hostile to the United States.”

The senator didn’t elaborate on his sources.

Instantly, Trump spokeswoman Kellyanne Conway — formerly but no longer casting aspersions on Comey’s role — said the director “did the right thing.”

Just how Comey’s image through the partisan prism became inverted becomes the question of the hour in Washington, D.C.

This trove of emails reportedly was discovered weeks ago.

Speculation abounds about why it took Comey until late last week to break the news. Did it take agents that long to determine if the materials merited notifying the director? Or were materials held back for maximum impact close to Nov. 8?

advertisement | advertise on newsday

Higher-ups at the Justice Department were said to be reluctant to make the disclosures so late in the campaign.

But, The Washington Post wrote, “officials said Comey put the department in an untenable position by informing them that he was sending a letter to Congress because he had an obligation to lawmakers or they would feel misled.”

Did it matter that the department already had been put in an awkward position last summer when former President Bill Clinton had his famous airplane chat with Attorney General Loretta Lynch?

Comey isn’t the only public figure whose good-guy/bad-guy status changed based on who he was or was not pursuing. There’s also Julian Assange, the Australian WikiLeaks hack-trafficker.

Six years ago, after WikiLeaks released nearly a quarter-million classified diplomatic cables, Rep. Peter King (R-Seaford) called on Clinton as secretary of state and Eric Holder as attorney general to figure out how to prosecute him for his “malicious actions.” Ex-GOP House Speaker Newt Gingrich called Assange an “enemy combatant.”

advertisement | advertise on newsday

“This is an act of war against the United States,” Gingrich said.

Now Assange — clearly targeting Clinton — made himself something of an asset to the Trump campaign by posting numerous embarrassing Democratic National Committee and Clinton campaign emails.

Trump backer Wendy Long — the Republican nominee against Democratic New York Sen. Chuck Schumer — supports a pardon for Assange. He took asylum in Ecuador’s embassy in London in 2012 to avoid extradition to Sweden, where he faces sexual assault charges.

“Assange is the only source of transparency and truth that most Americans now have about some of the most important matters affecting this election and our country,” Long said in a recent statement.

“We need him, we need his help, and we need him on the side of America.”

Even in the high-strung world of two-party politics, it takes a lot to go from enemy combatant to revealer of truths.