Although Sparta and Athens were allied at various times, they were the primary rivals during the Peloponnesian War (431-404 B. C.). Sparta emerged victorious with aid from most of the other Greek city-states, including Corinth and Elis; Sparta later gained the assistance of the Persians to defeat the Athenians. Previously, Athens and Sparta had joined forces to stop the second Persian invasion in the Greco-Persian Wars (499-449 B. C.), culminating in the Battle of Plataea (479 B. C.). The Spartans and Persians were joined by many of the other city-states, including Corinth and Megara.
Sparta, known for its military power, was generally in conflict with Athens, Corinth, and Thebes. During the existence of the Peloponnesian League (c. 505 to 365 BCE), Sparta formed an alliance with Elis, Tegea, Corinth, and other states. By joining this alliance system, the other states said that they would maintain the same allies and rivals as Sparta, and they provided troops to Sparta. As a result, Sparta gained control over the Peloponnese during this time period. During the invasion of Xerxes, the Persian king, in 480 BCE, Sparta was briefly allied with Athens. However, during the Peloponnesian Wars of 460 to 446 BCE and 431 to 404 BCE, Sparta fought against Athens and won, with the help of the Persians. Sparta later fought the Corinthian Wars from 396 to 387 BCE against Athens, Thebes, Corinth, and Persia.
Athens formed the Delian League in 478 BCE to free city-states in eastern Greece from Persian control. The league included over 300 members and was dominated by Athens. Most of Athens' allies were from Greece, mainly from Ionia and the islands. There were also non-Greek states represented in the alliance. Members included Chios, Byzantium, Paros, Thasos, Samos, Lesbos, Naxos, Lindos, and others. After Athens's defeat in the Peloponnesian War, the league was disbanded in 404 BCE. During the Peloponnesian War, Athens fought at different times against Sparta, Corinth, and other states.
They really didn't have any allies. The city-states always fought one another for supremacy. They were allies only to fight a common enemy. That was basically the only time they were allies.