The marathon may have ancient roots, but the foot race’s official length of 26.2 miles wasn’t established until the 20th century. The first organized marathon was held in Athens at the 1896 Olympics, the start of the Games’ modern era. The ancient games, which took place in Greece from around 776 B.C. to A.D. 393, never included such long-distance races. The idea for the modern marathon was inspired by the legend of an ancient Greek messenger who raced from the site of Marathon to Athens, a distance of about 40 kilometers, or nearly 25 miles, with the news of an important Greek victory over an invading army of Persians in 490 B.C. After making his announcement, the exhausted messenger collapsed and died. To commemorate his dramatic run, the distance of the 1896 Olympic marathon was set at 40 kilometers.

For the next few Olympics, the length of the marathon remained close to 25 miles, but at the 1908 Games in London the course was extended, allegedly to accommodate the British royal family. As the story goes, Queen Alexandra requested that the race start on the lawn of Windsor Castle (so the littlest royals could watch from the window of their nursery, according to some accounts) and finish in front of the royal box at the Olympic stadium—a distance that happened to be 26.2 miles (26 miles and 385 yards). The random boost in mileage ending up sticking, and in 1921 the length for a marathon was formally standardized at 26.2 miles (42.195 kilometers).

Today, marathon races take place everywhere from the North Pole to the Great Wall of China. In America alone, there are now more than 1,100 marathons each year. For decades, marathons were only open to male athletes. The Boston Marathon, which kicked off in 1897 and is the world’s oldest annual marathon, began allowing female competitors in 1972, while the first Olympic marathon for women wasn’t held until 1984. In 1976, an estimated 25,000 runners finished marathons in the United States; by 2013, the estimated number of competitors who completed a 26.2-mile course had soared to 541,000.