Katharine Weymouth, publisher of The Washington Post, addresses employees about the sale of the newspaper to Jeff Bezos, founder of Amazon.com. (Marvin Joseph/The Washington Post)

Katharine Weymouth knew when she talked to her uncle Don Graham about the possibility of selling The Washington Post that she was asking him to put her out of a job. She knew that any new owner would want to appoint a publisher of their choosing, which would effectively end the Graham family’s eight-decade run of leadership.

But as she sat with owner Jeffrey P. Bezos two weeks ago at one of their semi-regular meetings, beaming about the company’s progress — including record-setting Web traffic — she did not know that her time was up. Until, to her surprise, he told her that he was replacing her with Politico cofounder Frederick J. Ryan Jr., who would start in October.

“Obviously he was going to get his own team,” Weymouth said Tuesday. “When people buy a company, the existing team rarely stays for longer than a year. I just was expecting to at least finish this year. And we are having an awesome year.”

Weymouth, 48, who has been at the paper for 17 years and has served as publisher since 2008, sent an e-mail to the staff announcing her departure Tuesday morning. “The greatest honor of my life has been serving as publisher of The Post these past seven years, working with all of you,” she wrote.

She has been at the helm of the newspaper during perhaps its most tumultuous period, as digital media became more dominant, the economy fell into a deep recession and the advertising industry experienced a sea change, driving revenue away from venerable print publications.

Under Weymouth, The Post’s newsroom shrunk from about 800 full-time staffers to fewer than 550, as she presided over several rounds of cuts in an attempt to meet shareholder demands for profitability. As pressure continued in early 2013, she approached Graham, the newspaper’s chief executive, and suggested he consider selling The Post to save it. He agreed and quietly negotiated a $250 million deal with Bezos, the pioneering founder of Amazon.com.

Weymouth received her heaviest criticism for a decision in 2009 to host a series of off-the-record “salons” at which lobbyists were invited to pay to attend exclusive dinners with executives and politicians in her home. That blunder will appear in her obituary, she admits, although the salons were planned by several Post executives and editors and were canceled before the first one occurred.

Soon after becoming publisher she named Marcus Brauchli to succeed longtime executive editor Len Downie. But the choice proved to be ill-fated, as their relationship quickly soured and morale in the newsroom plummeted. In late 2012, she replaced Brauchli with longtime Boston Globe editor Martin Baron.

“People make mistakes, and I think the key is to learn from them and correct them,” Weymouth said Tuesday from her sixth-floor office, where the shelves are lined with photos of her three children and her legendary grandmother, Katharine Graham. “I hope and think I also made some good decisions that put us in a really good place going forward.”

Weymouth grew up in New York, studying ballet and mingling among the bigwigs routinely hosted by her mother, journalist and socialite Lally Weymouth. But Katharine Weymouth is less enamored by celebrity. She attended Harvard, Oxford and Stanford Law School before moving to Washington to practice at Williams and Connolly. When a position on The Post’s legal team opened up, she took it. She then became the vice president of advertising — and Graham’s heir apparent.

But there had long been a question of why Weymouth would want the job of publisher. By 2008 she was a divorced single mother — and to outsiders, it did not seem that she needed either the stress or the money that would come with a promotion. “I didn’t know the economy was going to fall out,” she says “But I knew that I was taking on a job that would be difficult. But I wanted to — because I felt like I could help us get through the transition.”

And it was clear to everyone around Weymouth that she wanted to continue what her grandmother had built.

Washington Post owner Jeffrey P. Bezos is replacing publisher Katharine Weymouth with Frederick J. Ryan Jr., a former Reagan administration official who was part of the founding leadership team of Politico. Here are some facts to know about him. (The Washington Post)

“She very much felt the need to live up to her grandmother’s legacy,” said Post senior editor Tracy Grant. “She understood that what her grandmother did was to lean in before that was a term of art. And what she did, she did in a time that was more difficult than anybody who had gone before her.”

Weymouth’s stylish appearance — she often came to work in well-tailored, brightly colored dresses and four-inch heels — occasionally made waves in the newsroom, but over time she endeared herself to staffers with her approachability and candor.

“She knows a lot about the individuals who work in this newsroom and has been very supportive of many, many people, without any grandstanding or making a big production of it,” says Anne Kornblut, a deputy national editor.

Weymouth most notably juggled the dual role of parent and publisher three years ago when she spent three weeks in a New York hospital by the side of her youngest child, Bridget, when the 7-year-old underwent 10 surgeries after a serious horse-riding accident. During the entire time, Weymouth ran The Post from a distance.

Top editors at The Post note that Weymouth strongly backed their coverage of Edward Snowden and the National Security Agency. “She did not flinch in supporting the newsroom in that work,” Baron said.

Perhaps the most unheralded change Weymouth made involved the hiring of a new vice president of technology, Shailesh Prakash. Under Prakash, The Post has become a vastly more tech-centric, innovative newsroom.

“The most important thing that occurred under [Weymouth’s] tenure by far was that we were able to make a transformation from a media company to a computer-engineering company,” says managing editor Emilio Garcia-Ruiz. “The moves that were made . . . completely changed the relationship with us and technology. . . . She positioned us really, really well to compete with not only traditional media companies, but also with digital-first companies.”

Baron said this will be Weymouth’s enduring legacy. “They will see someone who helped this organization make a very difficult transition to the digital age. She was willing to do that and took a lot of flak for it,” he said. “She knew where we needed to go, and went there — and did it under very difficult circumstances.”

Weymouth says she is not sure what she’s going do next, beyond granting her daughter’s request to “pick me up at school tomorrow. And then the next day? And the next day?” Weymouth is sure there will be an interesting professional chapter to come, though she leaves the job and the company with obvious sadness.

“It’ll be hard,” she says. “I’ve been here 17 years. And of course it’s my family and I kind of grew up with it. I love it. I love everyone here. So it’ll be weird, but I’ll be rooting from the sidelines.”

CORRECTION: An earlier version of this article said that the number of newsroom positions was reduced from about 800 to fewer than 550 under Weymouth’s tenure. Those numbers referred only to full-time positions.