A Flydubai flight from Dubai to Tel Aviv made an emergency landing in Saudi Arabia on Wednesday after what Israeli officials said was a stabbing in the cockpit and an attempt by one pilot to crash the plane.

Everyone aboard survived. Passengers and crew members subdued the attacker as the Boeing 737 Max 8, Flight FZ1073, turned toward Tabuk, in northwestern Saudi Arabia, about 270 miles from its destination. Both pilots were injured and taken to a hospital, according to Cluster2, which operates Tabuk’s airport. Prime Minister Benjamin Netanyahu of Israel said Saudi Arabia had arrested the suspect, whom officials identified as the co-pilot, and put the number of lives saved at 174.

The flight left Dubai just after 7 a.m. local time with a scheduled flying time of about three hours. Roughly two and a half hours in, tracking data showed, the jet dropped from its cruising altitude near 34,000 feet to about 17,000 feet — a fall of 17,400 feet in less than two minutes, according to data reviewed by CNN. The pilots first transmitted the 7700 code for a general emergency, then switched to 7500, the signal for unlawful interference, before the plane landed in Tabuk at 9:45 a.m. The alerts prompted Israel to scramble warplanes, an Israeli official said, and Mr. Netanyahu convened a security consultation with his defense minister.

In a video statement, Mr. Netanyahu said one pilot had stabbed the other and appeared to try to crash the plane with its passengers. Citing an Israeli passenger he spoke to by phone, he said the passenger and a crew member broke through the cockpit door and stopped the pilot, and that another crew member then steadied the aircraft. A person familiar with a Saudi investigation said those who intervened included members of Israel’s security forces and air marshals; the person was not authorized to speak publicly.

By Wednesday evening, Mr. Netanyahu had identified the stabbed captain as Smit Machchhar, an Indian national, writing on X that despite his wounds he fought back, resisted, opened the cockpit door and let passengers and crew overpower the attacker. “He is a true hero,” Mr. Netanyahu wrote. India’s embassy in Riyadh said Captain Machchhar was being treated in Tabuk and was reported to be in stable condition.

Two Israeli sources told CNN they suspected the co-pilot had tried to hijack the plane after stabbing the captain, and said it was not yet clear whether he meant to crash it or to land and take hostages. Two Israeli officials told CNN that one of the pilots was Omani, with one saying the Omani national was the co-pilot and the presumed attacker. Oman and Israel have no diplomatic relations, and an Israeli official said investigators were asking how he had obtained clearance to fly to Israel.

The airline itself gave a different cast to the episode. Flydubai said only that an “altercation occurred in the flight deck” and that on-duty crew members secured the plane and landed it safely. The South Korean newspaper Chosun Ilbo reported that the airline had described a brawl between a Ukrainian pilot and a Russian pilot. Those accounts sat awkwardly beside the Indian captain named by Mr. Netanyahu, and Flydubai did not reconcile them.

Passengers described terror in the cabin. Yasmin Abukasis said her daughter Miriam phoned from the plane and told of hearing screams, of a man with a knife forcing a pilot to the floor and of blood. “She said it’s crazy, crazy time,” Ms. Abukasis told Reuters. “It’s very hard to explain what’s happened there, but it was big stress.” Video reviewed by The Associated Press showed two bloodied men on the floor and others guarding the cockpit door. “We are guarding the pilot,” one person says in Hebrew. A passenger told Israel’s i24 channel there were moments she believed she would die.

Israeli officials were quick to assign motive even as details shifted. Defense Minister Israel Katz called it a jihadist attack meant to kill everyone aboard, and Itamar Ben-Gvir, the national security minister, posted on X about “a terrorist who planned to crash the plane and murder the 180 Israelis on board.” Two Israeli officials, speaking anonymously to brief reporters, told CBC the government assessed it as an attempted terror attack rather than a mental health episode. But hours earlier, Doron Spielman, a spokesman for the prime minister’s office, had told Reuters it was not believed to be a hijacking, calling it a “different incident.”

A range of Israeli agencies, including Shin Bet, Mossad, the military and the transportation ministry, are investigating, an Israeli official told CNN. Neither Saudi Arabia nor the United Arab Emirates commented publicly. The Dubai-Tel Aviv route has grown popular with Israelis since the two countries normalized ties in 2020, and Saudi Arabia — which has no relations with Israel — lifted its ban on Israeli overflights only in 2022. The incident came a week before the anniversary of the Hamas-led Oct. 7, 2023, attack and weeks before an Israeli election.

A Flydubai rescue flight carried the passengers from Tabuk to Ben Gurion Airport, landing at 3:34 p.m. GMT, where Mr. Netanyahu was on hand to greet them. Yair Lapid, the opposition leader, called the welcome “cheap politics.”