Kamworor of Kenya held off countryman Wilson Kipsang to win his first major marathon. The TCS NYC Marathon was broadcast live on Channel 7.
Flanagan crossed the finish line in a time of 2:26:53 - the second fastest ever by a U.S. woman - to defeat Mary Keitany, the 35-year-old Kenyan who has won the New York City Marathon the past three years.
Keitany had won three straight New York marathons, but Flanagan pulled away from the Kenyan great with about three miles to go.
The American cried and yelled as she approached the finish line all alone.
"It's indescribable," the 36-year-old Flanagan said. "It's a moment I'm trying to soak up and savor."
The last American woman to win New York was Miki Gorman, who won consecutive titles in 1976-77.
Flanagan finished second in New York in 2010 in her marathon debut, but hadn't run this race since. After a fracture in her lower back kept her out of the Boston Marathon, Flanagan trained hard for New York with an eye on Keitany.
On the podium, Flanagan put her hands over face and began to cry again when she was announced the winner. She turned to hug Keitany before accepting her medal.
"This is the moment I've dreamed off since I was a little girl," Flanagan said.
Flanagan had said she may retire if she won New York. She didn't immediately make an announcement regarding her future.
On the men's side, Kamworor edged Kipsang with a time of 2:10:53. Kamworor separated from the pack late and seemed like he would cruise to his first major marathon victory, but Kipsang appeared on his heels in the final stretch.
Kipsang didn't have enough to catch Kamworor, though. The 24-year-old winner kissed the pavement right after crossing the finish, then turned to embrace Kipsang.
American running great and 2009 New York winner Meb Keflezighi completed his 26th and final marathon in 11th place at 2:15:29, collapsing as he crossed the finish.
"Thank you New York for showing up today," Keflezighi told the crowd. "Cheering me on and showing that vibrant energy."
The race went off without interruption five days after the bike path terror attack killed eight in lower Manhattan. Police had promised an unprecedented effort to secure the course, a plan including hundreds of extra uniformed patrol and plainclothes officers, roving teams of counterterrorism commandos armed with heavy weapons, bomb-sniffing dogs and rooftop snipers.
Mayor Bill de Blasio said the city was expecting 2 million fans to line the course.
The Associated Press contributed to this story.