Army specialist Samuel Kosgei won his second Marine Corps Marathon title and Vienna resident Perry Shoemaker her first, with both taking control of their respective races in the final miles.

Kosgei, 32, created a gap on Desta Morkama by running 5:07 for the 24th mile, after having averaged 5:36 for the previous three.

“I looked at my watch after that mile and was a little scared,” Kosgei said. “I didn’t think I was going much faster than 5:20. The last two miles were hard, but I knew I could finish strong.”

He finished in 2:23:53, 36 seconds ahead of Morkama, 31. Oscar Ceron Santos , an officer in the Mexican Navy, finished third in 2:25:03. He finished second in 2015.

Meanwhile, Shoemaker overcame Meghan Curran, who, like Kosgei, had won the 2014 race. Curran had a 66-second lead at 18.6 miles, running a pace that All-Army Team Coach Col. Liam Collins admitted was a little more aggressive than they had planned. Curran is an Army reservist and recently moved to Denver for graduate school.

Perry Shoemaker raises her arms while crossing the finish line to win the women's division of the 41st Marine Corps Marathon in 2:51:48. (Toni L. Sandys/The Washington Post)

Although humid temperatures in the high 60s had forced her to scale back her original race plan, Shoemaker, 45, had worked her way into second place when she started hearing during mile 23 that she was gaining on Curran, 30, who was struggling with gastrointestinal distress.

“I saw my husband a mile later, and he said [Curran] had to walk,” Shoemaker said. “I made a push to catch up to her there.”

By 24.8 miles, Shoemaker was a second back, and she went on to a 91-second margin of victory in 2:51:48. Arlington’s Nicole Irving, 24, was third in 2:53:32.

Shoemaker was all too familiar with last-minute struggles. After finishing second at the Army Ten-Miler three weeks ago, she started feeling back pain that forced her to take seven days off all exercise.

“I really wasn’t sure I was going to run the race,” she said. “Running Marine Corps was my plan all along, but I started looking at whether I should go to Philadelphia or Richmond instead. The injury probably would have kept me from training much more, and this was a good weekend for my family because nobody had anything scheduled. I figured I would give it a try and see how I felt and drop out if it got too painful.”

Shoemaker is relatively new to competitive running, taking it up when her family moved from Pittsburgh in 2011. She finished fourth at the next year’s Marine Corps Marathon and has been a mainstay in the local competitive-running scene since.

Though the race doesn’t offer prize money, both Kosgei and Morkama believed a victory would pay off later on. Kosgei hopes it will burnish his résumé and help him make the Army’s World Class Athlete Program, which is based in Colorado Springs and put five athletes on the U.S. Olympic track team last summer. He has done most of his training at Fort Riley in Kansas, where he works as a medic.

“I would like to train with those guys,” he said. “I like Fort Riley — they let me train in the mornings — but having fast training partners would help me get better.”

Like four of those five WCAP athletes, Kosgei was born in East Africa. He came from Uganda to run at Lamar University and became a U.S. citizen when he joined the Army.

Morkama is a recent transplant to Arlington, coming on a six-month business visa from Ethiopia. He has run seven marathons under 2:20, all in Europe, but his manager, Arlington’s Jay Wind, said a victory at Marine Corps likely would open more doors for Morkama in the United States than a top-10 finish in a European marathon.

The course was altered to accommodate the Metro SafeTrack restrictions that kept the system from opening at 5 a.m. ahead of the 7:55 a.m. start. An hour-long window gave latecomers a chance to race, but they were still up against a 1:15 p.m. deadline to reach the 14th Street bridge. Nearly two miles were cut from a trip north on Rock Creek Parkway, and runners instead were routed around a Pentagon parking lot and farther south in Crystal City. Runners also managed the trip to and from National Harbor, the new home of the pre-race expo after years of moving between the D.C. Armory and Washington Convention Center.

In the end, 19,724 runners finished, including Arlington’s Al Richmond, who has completed all 41 Marine Corps Marathons. He ran it in 6:39:47. Will Brown, the other remaining “Ground Pounder,” did not finish.