ALEXANDRIA, Va. (AP) — Walmart agreed Thursday to pay $282 million to settle civil and criminal allegations of overseas corruption, including payment through a Brazilian subsidiary of more than $500,000 to an intermediary known as a “sorceress” for her uncanny ability to make permit problems disappear.

The settlements include civil charges filed by the Securities and Exchange Commission as well as a guilty plea by Walmart’s Brazilian subsidiary to a criminal charge filed in federal court in Alexandria, Virginia.

Criminal prosecutors went after Walmart under the Foreign Corrupt Practices Act, which prohibits American companies operating abroad from using bribery and other illegal methods.

Walmart’s foreign practices have been under investigation since 2012.

Walmart said the two settlements constitute a global resolution of federal investigations that stretch back to 2012 and have collectively cost the company more than $900 million.

“We’re pleased to resolve this matter,” said Walmart President and CEO Doug McMillon in a statement. “Walmart is committed to doing business the right way, and that means acting ethically everywhere we operate. We’ve enhanced our policies, procedures and systems and invested tremendous resources globally into ethics and compliance, and now have a strong Global Anti-Corruption Compliance Program.”

A representative of Walmart Brazil said the company would not comment.

The plea agreement filed in federal court in Alexandria shows Walmart has agreed to pay $138 million to avoid prosecution, while its Brazilian subsidiary, WMT Brasilia, pleads guilty to a single violation of the Foreign Corrupt Practices Act.

Later Thursday, the SEC announced a $144 million settlement against Walmart for “failing to operate a sufficient anti-corruption compliance program” in Brazil, China, India and Mexico.

“Walmart valued international growth and cost-cutting over compliance,” said Charles Cain, chief of the SEC Enforcement Division’s unit overseeing FCPA violations. “The company could have avoided many of these problems, but instead Walmart repeatedly failed to take red flags seriously and delayed the implementation of appropriate internal accounting controls.”

The criminal case focuses on corruption that occurred in Brazil in 2009 and 2010, and that the subsidiary’s corrupt acts caused the parent company to submit inaccurate financial records. In particular, the payments to the intermediary were recorded as payments to a construction company, even though there were numerous red flags indicating the intermediary was actually a government official. Walmart Brazil was barred at the time from hiring civil servants.

The court papers do not identify the intermediary, but describe her in some detail: It says she became known inside Walmart Brazil as a “sorceress” or “genie” for her “ability to acquire permits quickly by ‘sort(ing) things out like magic.'”

The plea agreement also includes a provision barring the Brazilian subsidiary from making public claims or issuing press releases contradicting the facts outlined under the plea agreement.

“For more than a decade, Walmart experienced exponential international growth but failed to create safeguards to protect against corruption risks in various countries,” said G. Zachary Terwilliger, U.S. Attorney for the Eastern District of Virginia, which negotiated the criminal plea.

Walmart’s foreign practices have been under investigation since 2012; The New York Times won a Pulitzer Prize for reporting that year exposing millions of dollars in bribe payments made by Walmart executives to facilitate growth in Mexico.

According to the SEC, companies including Halliburton, Anheuser-Busch InBev, JPMorgan and Panasonic Corp. reached settlements under the Foreign Corrupt Practices Act ranging from $6 million to $264 million in recent years. Last year a Brazilian energy company agreed to pay nearly $1.8 billion.

Bentonville, Arkansas-based Walmart, one of the world’s largest retailers, recently reported quarterly earnings of $3.84 billion. It announced last year that after “a thoughtful and deliberate review,” it decided to sell 80% of its stake in Walmart Brazil to Advent International, at a loss of $4.5 billion. At the time, the subsidiary had 438 stores in 18 Brazilian states.

AP Correspondent Yesica Fisch in Rio de Janeiro and AP Business Writer Marcy Gordon in Washington contributed to this story.