As the Lion Air crew fought to control their diving Boeing Co. 737 Max 8, they got help from an unexpected source: an off-duty pilot who happened to be riding in the cockpit.

That extra pilot, who was seated in the cockpit jumpseat, correctly diagnosed the problem and told the crew how to disable a malfunctioning flight-control system and save the plane, according to two people familiar with Indonesia’s investigation.

The next day, under command of a different crew facing what investigators said was an identical malfunction, the jetliner crashed into the Java Sea killing all 189 aboard.