NEW YORK -  Shalane Flanagan became the first American woman in 40 years to win the New York City Marathon on Sunday, joining Kenya's Geoffrey Kamworor in winning a first major marathon crown just five days after a deadly Manhattan truck attack that left eight people dead.

Flanagan, coming off a back injury that kept her from racing at Boston, captured her breakthrough title at age 36 in 2hrs 26mins 53secs and was in tears on the podium. "This is a moment I've dreamed of since I was a little girl," Flanagan said. "It's indescribable. These are the moments we dream of to realize our potential and see how incredible we can be."

Expanded security lined the route of the world-famous race, which saw an estimated 50,000 runners from more than 125 nations compete over 26.2 miles (42.1km) across the city streets. New York's recent tragedy revived memories of the 2013 Boston Marathon that was targeted by bombers, but the carnage also helped inspire Flanagan's triumphant run. "It has been a tough week for New Yorkers and a tough week for our nation and I thought what better gift than to make our nation and our people smile," Flanagan said. "I thought of that when I began to feel the pain."

Not since Miki Gorman in 1977 had a US woman won on the "Big Apple" streets. Kamworor took his first victory at the distance in his seventh marathon start. Two years after losing the lead late in the 26.2-mile race, Kamworor held off compatriot Wilson Kipsang to win in an unofficial time of 2hrs 10mins 53secs. "I'm so happy. I feel so great to be the champion," Kamworor said. "This is my first marathon victory. I'm so happy and so delighted."

Kipsang, the 2014 New York champion, was three seconds back with Ethiopia's Lelisa Desisa third in 2:11:32. Kamworor, 24, settled for second in 2015 to Kenyan Stanley Biwott after being overtaken late in the race. Kipsang, 35, won in Tokyo earlier this year but quit after 30km in September's Berlin Marathon.

Eritrea's Ghirmay Ghebreslassie, the 2016 winner, started strong in defending his crown, surging ahead twice but being overtaken quickly by the pack each time. Kamworor made his move at mile 21 and held off the fast-closing Kipsang at the line in Central Park. "New York is very amazing. The course is fantastic," Kamworor said. "I'm looking forward to coming back next year."

Flanagan, the 2010 New York marathon runner-up, was sixth in last year's Rio Olympic marathon. She was the 10,000m runner-up at the 2008 Beijing Olympics. Kenya's Mary Keitany, who was chasing her fourth consecutive New York women's victory, settled for second, 61 seconds behind Flangan, with Ethiopia's Mamitu Daska third in 2:28:08.

After a slow pace in the first half of the race, Keitany took the lead just after the midpoint and surged at 15 miles, shrinking the front pack to nine before slowing the pace once again. At 21 miles, Keitany, Flanagan and Daska pulled away and at mile 23, Flanagan grabbed the lead for good. New York City Mayor Bill de Blasio said the event being staged as planned was "a terrorist's worst nightmare" for bringing together people from a variety of cultures with resiliency despite the deadly attack.

"This day is incredibly important for New York and the entire country," De Blasio said. "We're standing up to terrorists. "We have 2 million people along this route. It goes off on schedule despite an attack in our city this week. This sends a message to the whole world. "Look at that unity. Look at that example -- live and let live. It's everyone getting together for a common cause -- it doesn't matter what background you are from. This event is life affirming every year but this year more than ever."