"This is a moment I've dreamed of since I was a little girl", the 36-year-old Flanagan said.
Thousands of police lined the course as part of heightened security because of the incident. She was also the 10,000m runner-up at the 2008 Beijing Olympics.
Before Flanagan's performance Sunday, Miki Gorman in 1977 was the last American woman to win the famed marathon.
Marblehead native Shalane Flanagan won the New York City Marathon on Sunday, becoming the first American woman in 40 years to accomplish that feat.
When crunch time came it was Flanagan, not Keitany, who dominated, impressively leading the final three miles. "This is my first marathon victory".
After taking the lead in the 23rd mile, the 24-year-old 2015 NY runner-up had to contend with Kipsang, whose final push brought him ever so close to his countryman.
Kamworor, who had finished second in 2014 behind Wycliffe Kipsang, was this time around the master as he broke away from among others Kipsang and Ethiopian Desisa Lelisa and Lemi Berhanu in the last three kilometers to win.
"I'm so happy. I feel so great to be the champion", Kamworor said.
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.
Former victor Meb Keflezighi, who was running his final competitive marathon at age 42, finished 11th in 2:15:29.
Switzerland swept the professional wheelchair divisions.
McFadden clocked 1:51:01 and third went to compatriot Amanda McGrory in 1:53.11.