Datuk Seri Anwar Ibrahim has withdrawn his candidacy for prime minister in the next general election.