Shalane Flanagan won the 47th New York City Marathon on Sunday, becoming the first able-bodied American to win the women's event in 40 years.

Miki Gorman won 1976 and 1977.

Flanagan posted an unofficial time of 2 hours, 26 minutes, 53 seconds. Kenyan Mary Keitany, who had won in New York in each of the past three years and set a world record in April, finished second with a time of 2:27:54.

"This is a moment that I've dreamed of since I was a little girl," Flanagan said in an interview with ESPN. "It's been a tough week for New Yorkers, and a tough week for our nation.

I thought of what a better gift than to make Americans smile today.

I was thinking of other people when it started to hurt, and thought of my family and just wanted to honor all of the people that have given their time to me to help me stand here today."

The marathon was run against the backdrop of heightened security after a terrorist attack earlier in the week killed eight people on a bike path in the city.

The race was described as a “very-well policed event, with many layers of security,” said New York Police Department Chief Carlos Gomez.

It was Flanagan's first marathon of the year following a left hip injury in January.

"Sometimes we don't realize in the moment when we feel like dreams are taken away that actually there's some delayed gratification down the road,"

Flanagan said on the television broadcast. "I think it was a blessing that I got injured this past winter and I came here full of energy and motivation and desire to put on the best performance of my life."

The Massachusettes native said earlier that if she were to win her first major marathon on Sunday, it could be her last 26.2-mile race at age 36. New York City is also where Flanagan's marathon career began. She placed second in her debut in 2010.

After covering the first half of the race in 1:16:18 in a 13-woman pack, Flanagan, Mamitu Daska of Ethiopia, and Keitany threw down a 5:26 mile between mile 20 and 21, the fastest of the race to that point, and made it a three-woman race. Flanagan covered the 23rd mile in 5:11, and the 24th mile in 5:04 to build a 28-second lead over Keitany with one mile to go.

Switzerland swept the professional wheelchair divisions.

Manuela Schaar won her first New York City Marathon in 1:48:09 after finishing second to American Tatyana McFadden for the past three years.

Five-time New York City winner McFadden finished second, nearly three minutes later.

Unlike last year’s men’s wheelchair race which came down to a photo finish and six hundredths of a second, Marcel Hug of Switzerland defended his title by a whopping 2 minutes, 19.82 seconds over John Charles Smith of Great Britain. Hug made his decisive move between mile 20 and 22 en route to his 15th major marathon victory in 1:37:21.