A flurry of diplomacy has eased tensions, officials said, after an incident risked triggering a wider war.