They helped stock indexes claw back losses from earlier in the week, caused by worries that worsening tensions in the Middle East.