Erastosthenes did it by comparing the angle of the shadow cast by a stick on the summer solstice at noon in two cities, Alexandria and Syene (now Aswan), which are about 800 km apart. What was special about Syene was that it is so close to the Tropic of Cancer line that the sun would hit the bottoms of wells on the solstice, meaning that he only needed one stick, in Alexandria, and the distance between the cities, to do his estimate. His error was about 2%.
He's also famous for the sieve of Erastosthenes for finding prime numbers and figuring out the earth's axial tilt.