The mayor of Istanbul and Turkish President Recep Tayyip Erdogan's main rival has been formally arrested and jailed pending trial over corruption charges.