Afghanistan's rival presidential candidates on Sunday signed a deal to share power after months of turmoil over a disputed election that destabilized the nation at a crucial time as most foreign troops prepare to leave.