This is how the Communists did it eastern Europe at the close of WW2. Control police and justice ministries, purge any internal opposition, then start arresting and imprisoning (or judicially murdering) political opponents until they got an "elected" Communist majorities the the respective parliaments.
Those who don't study history are doomed to repeat it.
Those who DO study history are doomed to stand by watching helplessly while everyone else repeats it.