WASHINGTON—About a week and a half after she was first elected to Congress in November 2012, Rep. Kyrsten Sinema signed up to compete in her first Ironman triathlon.

The only problem: The Arizona Democrat didn’t know how to swim or ride a bicycle. Full Ironman triathlons include a 2.4-mile swim, a 112-mile bike and a marathon run of 26.2 miles.

“I was afraid to put my face in the water,” Ms. Sinema said. “I started taking swim lessons just like a little kid.”

Almost six years later, Ms. Sinema is now competing against a fellow Ironman endurance athlete, Rep. Martha McSally (R., Ariz.), to win a U.S. Senate seat. The race to succeed retiring GOP Sen. Jeff Flake is believed to be the first Senate matchup between two Ironman World Championship finishers.

“I don’t think we’ve had two candidates running for office who are seasoned triathletes,” said Bob Babbitt, an Ironman historian. “We certainly haven’t had two candidates who are Ironman finishers who are running against each other.”

The contest is particularly unusual because men make up 80% of the full-length Ironman participants, according to the race’s organizers.

Rep. Martha McSally, the Arizona Republican running for the Senate, completed an Ironman triathlon in 1993. Photo: Ironman

Both Ms. Sinema, 42 years old, and Ms. McSally, 52, began their endurance training well before their political careers. Ms. Sinema started with running, a sport she could afford growing up in a poor household.

“All you need is a pair of shoes,” said Ms. Sinema, who said she now has 15 or 16 marathons under her belt. In October 2012, in the final stretch of her first congressional race, she watched a friend competing in a half-length Ironman. A few weeks later, Ms. Sinema signed up herself.

“It was a challenging year,” Ms. Sinema recalled. “I was serving my first year in Congress and learning how to cycle and swim.”

She took her first swim lesson in February 2013 and completed her first Ironman later that year in November. Two years later, she completed her second Ironman, the World Championship, in Kona, Hawaii, in just over 15 hours.

Ms. Sinema said she works out seven days a week, with a week of lighter training every four weeks. On Wednesday mornings, she teaches a bipartisan spinning class in the congressional gym.

“I wake up very early,” she said. “What you have to do in order to be successful in an endurance sport is be very disciplined and very dedicated and make it a priority in your life to get up and do the work.”

Rep. Martha McSally celebrates her Republican primary victory on Tuesday in Tempe, Ariz. Photo: Matt York/Associated Press

Ms. McSally, who grew up near the ocean in Rhode Island, has been swimming since she was young. After her father died when she was between sixth and seventh grades, she began running with her golden retriever.

“It was just part of my therapy, I guess, to get through those years,” she said. Her feelings around running became more complicated when her high-school track coach sexually abused her, said Ms. McSally.

She started cycling seriously in graduate school and stepped up her triathlon training while she was working as an Air Force instructor pilot in Del Rio, Texas, spending 12-hour days in T-37 planes with little air-conditioning. Once a week, Ms. McSally, who lived 18 miles from the base, would drive in to work with her roommate, forcing her to get back on her own.

“At the end of the day, no matter how late it was, no matter how tired I was, the only way I was going to get home was to run home,” she said.

The Senate is currently split with 51 Republicans and 49 Democrats. WSJ's Gerald F. Seib looks at three important Senate races to watch during the midterm elections. Photo: AP

Ms. McSally was selected for the Air Force team in a competition against the other military services in the 1993 Ironman. She finished the race in 10 hours and 45 minutes.

She has since expanded into hiking and mountain climbing. When she climbed Mount Kilimanjaro in Africa, she broke her kneecap and had to hike 10 miles injured on the descent.

“The training is important, but you can train the human body to do anything,” Ms. McSally said. “The most important element is the grit, the determination to believe you can do it and not quit.”

Rep. Kyrsten Sinema talks to volunteers at a Democratic campaign office on Tuesday in Phoenix. Photo: Ross D. Franklin/Associated Press

Ironman doesn’t track which participants are elected officials, but politicians who have made it across the finish line include 2016 presidential candidate Gary Johnson, now running for Senate in New Mexico as a Libertarian, and Sen. Jeff Merkley (D., Ore.).

“I was surprised that it was such a rare thing on Capitol Hill, because you’re here with a lot of folks who have been fairly driven about life,” Mr. Merkley said.

In 2016, when Mr. Merkley did an Ironman race in Tempe, Ariz., Ms. Sinema ran a few miles with him—after completing a 50-mile trail race in Maryland the previous day and then flying home, he noted. “She wasn’t even stiff or sore,” Mr. Merkley said.

Write to Kristina Peterson at kristina.peterson@wsj.com