Expressions (phrases, clauses, etc.), Ichidan verb
to end without incident; to not turn into something serious
こうして武田の悲鳴で通りすがりの船に気付いてもらえ、事なきをえました。In this way a passing boat noticed them, thanks to Takeda's scream, and they survived without incident.
Also written 事無きを得る【ことなきをえる】