The operation in Iran marked a sharp reversal for a president whose political rise was fueled by American fatigue with regime change.