Oedipus successfully answered the riddle posed by the sphinx who threatened anyone who wished to enter Thebes. She killed and ate any who answered wrongly.
When King Laius of Thebes learned from an oracle that he was destined to be killed by his own son, who would then marry his mother Jocasta, he decided that his newborn son could not be allowed to live. He ordered a servant to pierce the child's ankles and bind them with leather cords, and then leave him to die on a lonely mountain.
A passing shepherd found the infant and took him to Polybus, the king of Corinth. The queen, who had never had children of her own, was delighted that the gods had sent them a son. They named the boy Oedipus (swollen foot), and they loved him so much that they never told him he was adopted. Thus, when Oedipus heard an oracle proclaim that he would kill his own father and marry his mother, he decided to leave Corinth rather than bring harm to the parents he loved so much.
As he wandered, he came to a crossroads, where a haughty man in a chariot ordered him off the road and threatened him with a whip. Oedipus, who was after all a prince, was not accustomed to being spoken to like that, and he answered the man with equal arrogance. When the man tried to strike him, Oedipus pulled him from his chariot and killed him. The man's servant escaped, but Oedipus did not pursue him.
Eventually Oedipus came to the gates of Thebes. Guarding the gates was a terrible monster with the body of a lion and the head and torso of a woman. She allowed no one to enter or leave the city without answering the riddle that she posed. If the traveler could not answer correctly, she would kill and devour him. As no one had yet come up with the right answer, the sphinx was well-fed, and the city of Thebes was effectively cut off from all trade and all contact with the world outside the city walls.
When Oedipus reached the gates of the city, the creature posed her riddle: What walks on four legs in the morning, two legs at noon, and three legs in the evening? Oedipus solved the riddle, answering that man crawls on all fours in infancy, walks upright on two legs in adulthood, and uses a cane as a third leg in old age. The sphinx was so frustrated that Oedipus had answered her riddle that she threw herself from the city walls, and died there on the road in front of the city that she had terrorized for so long.
The Thebans were immensely grateful to Oedipus for having rid them of the monstrous sphinx. Their king, Laius, had been gone for over a year, and by now they had figured out that he was never coming back. In fact, they assumed he had been murdered by robbers during his travels, and that the sphinx's sudden appearance at their gates was actually a sign that their king had died. They were right, in a way, for the sphinx was sent by the gods, who were appalled that Oedipus had slain his own father. So closely bound was a king to his land, that Laius's unavenged murder had brought a curse down upon Thebes--and the sphinx was a manifestation of that curse.
In their gratitude the Thebans made Oedipus their new king, and gave him their widowed queen Jocasta as his wife. For many years the two were happy together, and for awhile Thebes prospered as well. But the curse that had first manifested in the form of the sphinx had not been lifted, for the king's death had still not been avenged. And though Oedipus did not know it, and had not intended it, he was guilty of two terrible crimes--patricide and incest. It was inevitable that his guilt would eventually bring harm to Thebes.
That harm came in the form of a withering drought, combined with a plague of barrenness. Crops did not grow, and none of the cattle, goats, or sheep bore young. Even the women of the city became barren. When Oedipus sent for the blind prophet Tiresias to learn the cause of his land's suffering, he was told that the murderer of King Laius had to be found and punished. He was determined to get to the bottom of this crime, but when all of the pieces finally fell into place, he was horrified to discover that he was himself the criminal. He had sworn that once the murderer was found, he would be driven into exile, but as more and more clues surfaced, a terrible dread began to fill his heart.
When he learned that he had been rescued from the mountain by a shepherd, and that his true parents were not the king and queen of Corinth, but Laius and Jocasta of Thebes, he realized that he had not escaped the fate predicted for him by the oracle. As Jocasta also began to understand what was happening, she fled to her rooms, where she hung herself. At first Oedipus refused to believe what he was hearing, but when the manservant who had fled the scene of Laius's murder appeared before him and told his story of how King Laius had died at the hands of a young man at a crossroads, Oedipus could no longer deny his own guilt. He went to find Jocasta, his wife and his mother, but instead he found her lifeless body hanging from a sash in her room. In despair, he took a brooch from her gown and gouged out his own eyes.
Then, in keeping with the punishment he had pronounced against the murderer of the king, Oedipus went into exile, accompanied only by his daughter Antigone. After many years of wandering, he arrived at the shrine of the Eumenides at Colonus, near Athens. There he died, after having atoned for his crimes by virtue of his years of suffering and sorrow. That spot remained sacred after his death, and brought great blessings to Athens, which had given shelter to the unhappy exile.