Janša served as Minister of Defence from 1990 to 1994, a post he had also held during the Slovenian War of Independence. Janša served as prime minister from 2004 to 2008, and again became prime minister in 2012, following an early election in December 2011. On 27 February 2013, Janša's second government was ousted in a vote of non-confidence. In June 2013, Janša was sentenced to two years in prison on corruption charges. The ruling was confirmed by Slovenia's higher court in April 2014, but after the Constitutional Court of Slovenia ordered a retrial for procedural reasons, the case later expired. Despite his party winning a plurality of votes in the 2018 Slovenian parliamentary election, Janša was initially passed over as a prime minister candidate as most parties refused to join a Janša-led government because of Janša's extremist views. After spending years in opposition, Janša was selected as prime minister-designate in March 2020 following the resignation of prime minister Marjan Šarec.