Yemen’s embattled president agreed tonight to a proposal by Gulf Arab mediators to step down within 30 days and hand power to his deputy in exchange for immunity from prosecution, a major about-face for the autocratic leader who has ruled for 32 years.