Strangely the question that everyone who does a marathon gets asked by non-marathon runners is, "You ran a marathon? How long was it?".
For the record, a marathon is not less than 26.2 miles, or 26 miles and 365 feet, 42.195 kilometers, and it can not be more than 1% greater than that distance (or roughly more than 42 meters longer).
The mistake that most everyone makes, including many marathon runners is why the distance is 26.2 miles. Most people believe that that is the distance that Pheidippides, a Greek messenger, ran to announce that the Greeks had defeated the Persians in the Battle of Marathon. However, the Greek historian Herodotus mentions Pheidippides ran from Athens to Sparta asking for help, then ran back; 150 miles each way or 300 miles total.
However the distance of the modern marathon was not fixed until May 1921 by the International Amateur Athletic Foundation, prior to that the distance was approximately 25 miles or roughly the distance from Marathon to Athens by the long route. The reason for 26.2 miles: that was the distance set for the marathon in the 1908 Olympics with the dramatic finish by Dorando Pietri.
By the way, all of this was pulled from Wikipedia's article on marathon, if you want to read it all yourself.