How did Muammar Qaddafi become the Leader of Libya?

In September 1969, a small group of junior military officers led by Gaddafi staged a bloodless coup against King Idris while he was in Turkey for medical treatment. His nephew, the Crown Prince Sayyid Hasan ar-Rida al-Mahdi as-Sanussi, had been formally deposed by the revolutionary army officers and put under house arrest; they abolished the monarchy and proclaimed the new Libyan Arab Republic.