But Flanagan, motivated and exhilarated, proved untouchable even for Keitany. With tears in her eyes, pointing and shouting (with maybe a few colorful words thrown in), Flanagan won the race with a time of 2 hours 26 minutes 53 seconds.

Keitany, who finished second with a time of 2:27:54, hugged Flanagan, who had the American flag already draped over her shoulders. Mamitu Daska, of Ethiopia, competing in the New York City Marathon for the first time, finished third with a time of 2:28:08.

Keitany was seeking to cap a career year, in which she won the London Marathon with a blistering time of 2:17:01, a women’s-only record. She had blown away the field here a year ago, winning by a margin (3 minutes 34 seconds) not seen in the women’s race since 1980.

It was clear almost from the start, though, that Sunday’s race was not going to follow the same trajectory. A pack of nine competitors consistently jockeyed with Keitany for the lead, including three runners making their New York debut: Kenya’s Betsy Saina; Ethiopia’s Mamitu Daska; and Sara Dossena, an Italian triathlete.

After 21 miles, the lead pack whittled to three: Keitany, Daska, and Shalane Flanagan, a 36-year-old from Massachusetts, who finished second in New York in 2010. Keitany finally removed her sleeves. The race was on.

The pace picked up, and all three runners continually traded positions. But as they made their way down Fifth Avenue, one runner began to break away. Surprisingly, it was not Keitany.

Flanagan entered the Engineers’ Gate into Central Park with a wide berth. In a bizarre decision, Keitany began to drift toward the east side of 5th avenue, away from Flanagan’s tail, before zigzagging back into the customary route. At that point, though, it was too late to catch the runner from Massachusetts — a second-place finisher in the New York marathon in 2010, but unbeatable Sunday.