South African President Thabo Mbeki agrees to resign