Perhaps you're thinking of the Battle of Marathon (490 BC)?
The Persians under Darius sent an expedition against Greece in response to their support of the Ionian revolt and burning of the regional capital at Sardis. The Persians disembarked from their ships in northeastern Attica and after a few days the Greeks met them at the plain of Marathon when their cavalry had left to graze (there is disagreement why their cavalry were not present for the battle). The rest of Persian army consisted of separate contingents of their subjects, including several peoples (e.g. the Medes) that were renowned in antiquity for their skills as archers. The ancient Greek way of warfare did not make use of archers, and so in the hopes of catching the Persians off-guard, the lines of hoplites sped up their normal rate of advance up to and into the Persians, and the Greeks then proceeded to push them back into a marshy area and routed a great deal of them before they could disembark. The Persians then tried to sail around the Cape of Sounion to take Athens by sea, but the Greek hoplites booked it back to the city in time to ward off another attack.