Walmart agreed Thursday to pay a total of $282 million to settle a U.S. bribery investigation in connection with the retailer's operations in Brazil, China and other countries.

Of that amount, the company will pay a $138 million to resolve Justice Department allegations that its Brazilian subsidiary secretly funneled more than $500,000 to an intermediary in order to secure government permits. Such payments are a violation of the Foreign Corrupt Practices Act (FCPA), a 1977 law that bars American companies operating abroad from using bribery and other illegal methods.

Walmart also will pay more than $144 million to settle similar charges by the Securities and Exchange Commission. The company allowed subsidiaries in the four countries to "employ third-party intermediaries who made payments to foreign government officials without reasonable assurances that they complied with the FCPA," the SEC said in a statement.

Get Breaking News Delivered to Your Inbox

Court documents filed in Alexandria, Virginia, say the corruption occurred in 2009 and 2010, and that the subsidiary's corrupt acts caused the parent company to submit inaccurate financial records.

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."

"Sorceress" with permits

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 SEC, companies including Halliburton, Anheuser-Busch InBev, JPMorgan and Panasonic Corp. have all reached multimillion settlements under the Foreign Corrupt Practices Act since 2016.

"Walmart valued international growth and cost-cutting over compliance," said Charles Cain, Chief of the SEC Enforcement Division's FCPA Unit, in a statement. "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."

Bentonville, Arkansas-based Walmart, one of the world's largest retailers, recently reported quarterly earnings of $3.8 billion. It announced last year that after "a thoughtful and deliberate review," it decided to sell 80 percent 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.