Shalane Flanagan announced Monday she's retiring from running after four Olympic appearances and after becoming the first American woman to win the New York City Marathon in 40 years.

Flanagan, 38, made the announcement on Instagram, writing that from 2004 to 2019 she's "given everything that’s within me to this sport and wow it’s been an incredible ride!"

"I’ve broken bones, torn tendons, and lost too many toenails to count. I've experienced otherworldly highs and abysmal lows. I've loved (and learned from) it all," Flanagan said. "Over the last 15 years I found out what I was capable of, and it was more than I ever dreamed possible."

WHY MARATHON WINNER SHALANE FLANAGAN IS A GREAT ROLE MODEL FOR WOMEN

In 2017, Flanagan became the first American woman to win the New York City Marathon since 1977, pulling away from Mary Keitany in the last three miles of the race for her first major marathon victory.

Keitany had won three straight New York City Marathons, but Flanagan pulled away from the Kenyan great with about three miles to go and finished with an unofficial time of 2 hours, 26 minutes, 53 seconds, about a minute faster than Keitany. At the time, she described the moment as "indescribable" when she approached the finish line all alone.

She went to defend her title in 2018 but finished third.

"Now that all is said and done, I am most proud of the consistently high level of running I produced year after year," she wrote Monday. "No matter what I accomplished the year before, it never got any easier. Each season, each race was hard, so hard. But this I know to be true: hard things are wonderful, beautiful, and give meaning to life."

SHALANE FLANAGAN BECOMES FIRST AMERICAN WOMAN TO WIN NYC MARATHON IN 40 YEARS

Flanagan, who said she has always "loved having an intense sense of purpose," will now focus on coaching and announced she is a professional coach of the Nike Bowerman Track Club in Portland, Ore., where she lives.

"However, I have felt my North Star shifting, my passion and purpose is no longer about MY running; it's more and more about those around me," she said. "All I’ve ever known, in my approach to anything, is going ALL IN. So I’m carrying this to coaching. I want to be consumed with serving others the way I have been consumed with being the best athlete I can be."

While she won't be appearing in this year's New York City Marathon, WABC-TV announced she has joined the broadcast team as a lead commentator.

In addition to her marathon title, Flanagan competed in the Olympics four times and won an Olympic medal in 2008. She initially was awarded a bronze but was upgraded to silver after the original silver medalist failed a drug test, according to Runner's World magazine.

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

While in her new role, Flanagan said she will continue to work with her coaches Jerry Schumacher and Pascal Dobert as an opportunity to "give back to the sport, that gave me so much."

"I believe we are meant to inspire one another, we are meant to learn from one another," she wrote. "Sharing everything I’ve learned about and from running is what I’m meant to do now."