Flanagan made her debut at the NYC Marathon in 2010, finishing second with a time of 2 hours, 28 minutes and 40 seconds - at the time, the best finish by an American woman in 20 years.
American women had not won in NY since Miki Gorman claimed her second consecutive title in 1977. Kenyan Mary Keitany, who had won in NY in each of the past three years and set a world record in April, finished second.
In men's event, Kamworor held off compatriot Wilson Kipsang's challenge to win at a time of 2:10:53. Flanagan, 36, is the American record holder in the indoor 3,000 meters, the indoor 5,000 and won a bronze medal that was upgraded to silver in the 10,000 in the 2008 Olympics.
But in the end it was Kamworor who won by three seconds in 2:10:53 with Ethiopia's Lelisa Desisa third in 2:11:32.
"I'm so happy. I feel so great to be the champion", Kamworor said.
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.More news: Don't forget to turn back clocks for Daylight Savings Time
More news: Lebanese prime minister resigns amid tensions with Hezbollah
More news: Jennifer Lawrence Gets Drunk With Kris Jenner, Strips Naked In Her Closet!
More than 50,000 runners from about 125 nations took part in the race across five boroughs.
Flanagan placed sixth in the women's marathon in at the Rio Olympics a year ago, the top American finish. "This is my first marathon victory".
Switzerland swept the professional wheelchair divisions.
Manuela Schaer stunned five-times champion Tatyana McFadden in the women's race, defeating the American by nearly three minutes in 1:48.09.
Repeat victor Marcel Hug gave Switzerland the men's title in equally dominant fashion, defending his championship in 1:37:21, more than two minutes ahead of British runner-up John Charles Smith.