NEW YORK — 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 the event in both 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.

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. 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 her 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.