International retail giant Walmart agreed to pay $282 million to settle charges over potentially illegal payments to foreign officials in Brazil, China, India and Mexico, the U.S. Securities and Exchange Commission announced Thursday.

The SEC said the company failed to operate an effective anti-corruption program to comply with U.S. law for more than a decade while it pursued international growth, and "repeatedly failed to take red flags seriously."

Walmart agreed to pay $144 million to settle the SEC investigation, and $138 million to settle a parallel criminal probe by the Justice Department, the SEC said in a news release.

Walmart agreed Thursday to pay a $138 million criminal penalty to settle Justice Department allegations that its Brazilian subsidiary secretly funneled more than $500,000 to an intermediary known as a "sorceress" for her uncanny ability to make permit problems disappear.

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.

The court documents say the corruption occurred 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" to indicate that the intermediary was actually a government official. Walmart Brazil was barred at the time from hiring civil servants.

The federal agreement does not identify the intermediary, but describes 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.

According to the Securities and Exchange Commission, companies including Halliburton, Anheuser-Busch InBev, JPMorgan and Panasonic Corp. have all reached multimillion settlements under the Foreign Corrupt Practices Act since 2016.

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.