CAIRO — President Hosni Mubarak of Egypt resigned his post and turned over all power to the military, ending his 30 years of autocratic rule and bowing to a historic popular uprising that has transformed politics in Egypt and around the Arab world.