Former Toyota Motor Corp. executive Julie Hamp left a Tokyo jail 20 days after police arrested her for violating Japan’s drug laws. U.S. Ambassador Caroline Kennedy helped secure the release, said an official.

Prosecutors decided not to indict Hamp, 55, who had been held by Tokyo police since June 18 on suspicion she imported the pain medication oxycodone, because the pills were meant for her physical condition and not for drug abuse.

She left the jail in Tokyo’s Harajuku district Wednesday afternoon in a silver Toyota Alphard. Kennedy spoke with Japanese authorities about the case against Hamp before her release, according to the U.S. official.

The legal woes for Hamp, who lasted just three months as Toyota’s first female executive, thrust Toyota into the position of defending efforts to boost diversity in its management ranks dominated by Japanese men. The automaker accepted Hamp’s resignation as communications chief less than two weeks after President Akio Toyoda hosted a press conference to vouch for her character and express confidence she hadn’t intentionally broken the law.

The U.S. official, who asked not to be identified discussing a private matter, said Kennedy’s role was one that American ambassadors are often called on to play on behalf of Americans imprisoned or accused of crimes in foreign nations.

Mark Toner, a State Department spokesman, told reporters in Washington that while he was sure Kennedy was involved “at some level” as U.S. ambassador, he couldn’t comment further.

In Hamp’s case, the unnamed U.S. official said, the embassy’s inquiries to Japanese officials and Kennedy’s personal involvement were in part the result of fears that the publicity the case generated was creating an unfair impression that the Toyota executive was guilty without any judicial proceedings.

The official also said ambassadors and other U.S. diplomats and legal attaches routinely discuss less prominent cases with their counterparts in foreign countries.

In those cases, as in this one, the official said, American representatives question foreign legal officials about the basis for arrests of U.S. citizens and the nature of the evidence against them, and do not seek any special dispensations from local laws, even when those differ from comparable U.S. law.

Toyota issued a statement after her release, apologizing for “any confusion or concern” the arrest may have caused. The automaker appointed Shigeru Hayakawa, whom Hamp was reporting to before her resignation, to replace her as chief communications officer effective Monday. Hayakawa, 61, joined the company in 1977.