SAN FRANCISCO — One of Apple’s former top lawyers is facing accusations of brazenly breaking the company’s insider trading rules that he helped draft, while profiting from stock sales and investments made after he received confidential information about Apple’s finances.

The allegations against Gene Levoff emerged in criminal and civil complaints filed Wednesday in a New Jersey federal court by the U.S. Justice Department and Securities and Exchange Commission.

Levoff, 45, realized gains and avoided losses totaling more than $600,000 in illegal trades made periodically from 2011 to 2016, based on estimates provided in the documents.

Before Apple fired him last September, Levoff held various roles in Apple’s corporate law department starting in 2008. Apple promoted him to senior director of corporate law in 2013 overseeing as many as 30 attorneys. He also had responsibility for drawing up company policies designed to prevent employees from violating federal laws that prohibit stock market trading based on privileged information.

Levoff’s alleged misconduct “was particularly egregious given his responsibility for implementing the company’s insider trading compliance policy,” said Antonia Chion, associate director for the SEC’s enforcement division.

Kevin Marino, the attorney representing Levoff in the proceedings, said he is looking forward to fighting the allegations.

If he is convicted in the criminal case, Levoff faces a prison sentence of up to 20 years and a $5 million fine.

Levoff broke the law repeatedly, the complaints allege, by leveraging his position on a special committee that reviewed key numbers contained in Apple’s quarterly earnings reports before the results were publicly announced.

His most brash move came in July 2015 when Apple was preparing to release its results for the April-June period of that year. As part of Apple’s disclosure committee, Levoff received a July 10 preview showing that the company’s sales of iPhones for the quarter had missed the targets set by Wall Street analysts — a shortfall that typically causes Apple’s stock to fall.

Levoff then sold nearly all of his Apple holdings — more than 70,000 shares worth about $10 million at the time — four days before the company released the results, according to the complaints. The day after those numbers came out, Apple’s stock fell by 4 percent. That downturn lumped Apple’s shareholders with collective losses of $32 billion on paper, but Levoff avoided about $345,000 in losses by selling shortly before the announcement, the government alleged.

Copyright 2019 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.