Thebes was , at different times , allied with Sparta when it was mutually beneficial to both . For example there was a Theban contingent , The Sacred Band , with Sparta at the Battle of Thermopylae . (Thebes effectively ended Spartan influence and prestige by defeating the Spartans at the Battle of Leuctra .)