TOKYO — The handwritten note was short, just three sentences long.
But it had a profound effect on Ayaka Shiomura, a legislator in Tokyo who had been taunted publicly by male colleagues for speaking out about the problems of working mothers in Japan.
“We never know when our actions will have the greatest impact,” Caroline Kennedy, the United States ambassador to Japan, wrote, “and it’s often not when we expect.”
That note two years ago, Ms. Shiomura recalled, “really helped me.” It lifted her from a depression over the criticism she faced from political rivals and on social media and inspired her to continue to fight for women’s rights. Months later, at a reception at the ambassador’s residence for female leaders, Ms. Kennedy greeted her with raised fists and told her, “Don’t let these troubles get you down.”
In multiple moments like these, Ambassador Kennedy, who will depart Japan next Wednesday after three years here, sought to convey to women across the country a quiet message of empowerment.
Dozens of American envoys will leave office next week, but few of them are as prominent as Ms. Kennedy, the daughter of President John F. Kennedy. Over the last three years, she helped manage relations with one of America’s most important allies, but her status as the first woman to hold the post may have been just as consequential for traditionally male-dominated Japan.
“I just think being a woman ambassador, and I think visible women in positions of leadership, does help change attitudes,” Ms. Kennedy said in an interview this month in her office at the United States Embassy in Tokyo.
The historic nature of Ms. Kennedy’s tenure is evident in an alcove down the hall from her office, where 30 portraits of past American ambassadors hang in three neat rows. Going all the way back to Townsend Harris, the first envoy to Japan in 1856, they are all men.
In Japan, where few women hold positions of authority and married women cannot use their original surnames, Ms. Kennedy, a trained lawyer and mother of three, was a role model for combining power and family as well as a vital supporter of the agenda of Prime Minister Shinzo Abe, who has said he wants women to play a larger role in business and politics.
Her influence as ambassador stemmed from who she was — not just a woman, but the daughter of President Kennedy, a beloved figure here as he is in the United States.
Among skeptics, her celebrity raised questions about her fitness for the job. She had no formal diplomatic experience before moving to Japan in late 2013, nor did she have special expertise in Japan.
A 2015 report by the Office of Inspector General highlighted Ms. Kennedy’s unfamiliarity with “leading and managing an institution the size of the U.S. Mission to Japan” and criticized a lack of communication within the embassy. On the campaign trail, President-elect Donald J. Trump mocked Ms. Kennedy, claiming “she’ll do anything they want, anything!” in reference to the Japanese government.
But those who have worked with her say she leveraged the good will associated with her family name — as well as her close ties to President Obama — to build strong relationships with people in the Japanese government, business community and broader public.
“She transformed herself from a celebrity into an influential public figure and statesman who became trusted, respected, liked and listened to,” said Daniel R. Russel, assistant secretary at the Bureau of East Asian and Pacific Affairs in the State Department.
Ms. Kennedy won public appreciation as she traveled across the country, visiting 35 of 47 prefectures. She rode in bicycle races in the Tohoku region devastated by the 2011 earthquake and tsunami, and showed a playful side when she appeared in a Santa hat in a wildly popular video (more than six million views and counting) mimicking dance moves from a popular Japanese television series.
When talking at conferences about women’s equality, one of her favorite causes, Ms. Kennedy did not hector her audiences, said Kathy Matsui, chief Japan equity strategist at Goldman Sachs in Tokyo and an adviser to Mr. Abe on women’s issues.
“She always talked about the history of women’s empowerment in the United States, which wasn’t always a stellar track record either, to say how far everybody has come,” Ms. Matsui said.
Ms. Kennedy acknowledged the slow pace of change in Japan on such practical matters as insufficient day care slots and labor law reform. “I don’t blame people for being frustrated,” she said. “But I feel that there is a real commitment here.”
While Japan has been one of America’s strongest allies since the end of World War II, Mr. Abe is a conservative, nationalist leader of the Liberal Democratic Party that has traditionally felt more aligned with Republicans in Washington.
“One of the things that she did behind the scenes was to make sure there was greater connectivity between these two ideologically opposed governments,” said Michael J. Green, a former Asia adviser to President George W. Bush and now at the Center for Strategic and International Studies.
Mr. Trump has not officially announced a new ambassador, but some news organizations have reported that William Hagerty, a Tennessee businessman, will be nominated. Ms. Kennedy, who once flirted with running for the United States Senate, will return to New York. Aides say she has no fixed plans, although they expect she will remain interested in Japan.
Mr. Trump has spooked some here with comments about trade and complaints about American military costs in Japan. Ms. Kennedy said the alliance between the two countries would remain strong.
“If I’ve learned anything,” she said, “it’s that this relationship is bigger than any one person.”
During her time as ambassador, Ms. Kennedy’s Japanese counterparts viewed her as someone who would listen to their perspective but fight hard for American interests.
“I think most people don’t know about this, but Ambassador Kennedy was an exceptionally tough negotiator,” Fumio Kishida, Japan’s minister for foreign affairs, wrote in an email. “When I could persuade her, I could persuade Washington, D.C., as well. On the contrary, when she gave me a firm negative response, I thought it was time for the Japanese side to come up with an alternative idea.”
Advisers to Mr. Abe showed her drafts of important speeches, including the prime minister’s speech on the 70th anniversary of the end of the war and his remarks at Pearl Harbor last month.
Ms. Kennedy said she pointed out what American audiences “might be listening for,” particularly when talking about wartime history.
It was in the area of historical reconciliation that Ms. Kennedy exerted her biggest sway. She played a central role in pushing for and organizing President Obama’s historic visit to Hiroshima last May.
“She was relentless,” said Ben Rhodes, the deputy national security adviser, who said Ms. Kennedy emailed him about the visit “multiple times a week for months.”
As for many American ambassadors in Japan, one of Ms. Kennedy’s biggest challenges came in dealing with the complex dynamics of Okinawa, which hosts nearly half of the roughly 50,000 American troops in Japan.
In December, Ms. Kennedy presided over a ceremony in which the United States officially returned nearly 10,000 acres of land in Okinawa to Japan. The handover upset some residents because the Japanese government agreed to build six new helicopter landing pads on the acres that the United States retained to use in jungle warfare training.
Some residents in Okinawa said they had hoped Ms. Kennedy would be more sympathetic to protesters who want the American military to greatly reduce its footprint.
“We had a hope when she was appointed as the U.S. ambassador to Japan, as a daughter of the symbol of democracy,” said Tomohiro Yara, a freelance writer and activist in Okinawa. “Sorry, the symbol was only a symbol.”
Ms. Kennedy said she understood the anger. “You may not hear it, but I think that certainly we did take actual practical steps,” she said, including the return of other land on Okinawa and moving an aircraft hangar to reduce noise. “So hopefully people will see that the U.S. is committed to making progress, reducing our presence.”