In 2007, he unsuccessfully ran for party president, losing to Zoran Milanović. Bandić won a fourth term in the 2009 mayoral election, when the mayor was for the first time directly elected. Later in the year, he announced his candidacy for Croatian president, and was automatically expelled from the SDP as the party already had a candidate. He subsequently lost the presidential election to the SDP candidate Ivo Josipović. As an independent, Bandić won the 2013 mayoral election against SDP's Rajko Ostojić. In October 2014, Bandić was arrested for suspected corruption. His deputies took over the mayoral role in his absence. Bandić returned to the position of mayor in April 2015, following a court ruling to release him from prison. He founded a new party and went on to win a sixth term in 2017.