WASHINGTON (AP) — Billionaire investor Carl Icahn, who resigned Friday from an unpaid post as President Donald Trump’s adviser on deregulation efforts, stepped down as The New Yorker was preparing to publish a lengthy article detailing Icahn’s potential conflicts of interest and questioning the legality of his actions.

Icahn said in a letter to Trump released Friday that he would resign to prevent “partisan bickering” about his role that Democrats suggested could benefit him financially.

The resignation came just three days before The New Yorker was scheduled to post its story online and begin selling printed magazines on newsstands. In the story, the magazine points out potential conflicts and even possible criminal law violations involving obscure rules that require oil refineries to blend ethanol into gasoline.

In his letter, Icahn wrote that he “never had access to nonpublic information or profited from my position, nor do I believe that my role presented conflicts of interest.”

But The New Yorker wrote that in 2012, Icahn, who made his name and fortune as a corporate raider, bought an 82 percent stake in CVR Energy, a Sugar Land, Texas, refinery. To comply with regulations designed to promote use of ethanol, refiners must blend the renewable fuel with their gasoline or buy credits from other refiners that are called “Renewable Identification Numbers.”

When Icahn bought his stake in CVR in 2012, the credits were cheap, about 5 cents each, so rather than equip refineries to add ethanol to its gas, the company just purchased credits. But by 2016 CVR was spending $200 million per year to buy them, and its stock value had dropped 70 percent from the prior year, the story said.

Icahn unsuccessfully tried to get the Obama administration’s Environmental Protection Agency to change the point at which the ethanol blending was required, making it closer to the gas pump so refiners weren’t responsible and CVR wouldn’t have to buy the credits, the magazine wrote.

Several weeks after Trump’s November victory, Icahn agreed to become special adviser to the president on regulatory reform, and CVR’s stock nearly doubled in value on the expectation that the renewable fuels rule would be changed, the magazine wrote.

On Dec. 22, the day after Icahn was formally declared a White House adviser, the price of the credits dropped. Then, on Feb. 27, news leaked that Icahn had struck a deal with the Renewable Fuels Association to change the ethanol blending requirement. That sent the price of credits down more, and it fell further when word leaked that an executive order on ethanol blending was imminent.

Previously the Renewable Fuels Association had opposed any changes, the magazine said. The association’s head later said he was told by Icahn that the blending point would be changed whether the association objected or not, so he agreed to take a deal to his board.

Early in the year, CVR actually was selling renewable fuel credits, the magazine wrote. It was able to buy them later at a discount to meet federal requirements, according to the story.

A day after news of the deal with the Renewable Fuels Association, the White House denied there was any plan to change the renewable fuel requirements, and no such change was made, according to the magazine.

Icahn’s attorney, Jesse Lynn, rejected allegations that Icahn exploited his relationship with Trump to make bets on the renewable fuel credits. He said the CVR board, which Icahn chairs, made decisions on when buy or sell credits. “Any suggestion that we had access to information that others didn’t is unequivocally false,” he told the magazine.

Richard Painter, a former chief White House ethics lawyer to President George W. Bush, told the magazine that a federal law makes it illegal for executive-branch employees to work on matters in which they have a financial interest. Lynn said the law doesn’t apply to Icahn because he had no official role or duty. But Painter said Icahn’s title was clearly an official one. He suggested the Justice Department should be investigating.

Painter, reached Saturday by The Associated Press, said Icahn faces potential legal exposure to insider trading laws as well as other fraud statutes “if he took information from the White House or government in violation of any relationship or trust.”

Despite being unpaid, his job title as adviser to the president exposes him to possible legal action, Painter said. “When you have a title like that, that’s ‘to the president,’ it’s very hard to argue that you’re not a government employee,” Painter said.

Efforts by The Associated Press to reach Icahn through a CVR spokeswoman Saturday were not successful.