By tragic accident.
In a common device of Greek tragedy, in an attempt to evade a fate given him by the Oracle at Delphi (that stated he would slay his father and marry his mother), he ended up doing it anyway without even knowing it. In this case, Oedipus never knew that his real father was Laius King of Thebes, but when Laius offended Oedipus by cutting him off at a crossroads, the latter retaliated by killing the former. Later on, he ends up outsmarting a sphinx. Then, he comes upon Thebes itself, where the people didn't realize that Oedipus had killed their king, but overjoyed that he had ended the sphinx's reign of terror and gave him the throne as reward.
Chat with our AI personalities
In the Greek version, Creon replaced Oedipus as the ruler of Thebes. In the Homeric version, Oedipus remains king and is not exiled even after the truth is known.