Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A hijacker who took dozens of hostages aboard a commercial jet over what appeared to be a "personal" matter involving a woman was arrested after an hours-long standoff Tuesday, authorities said.

The Ministry of Foreign Affairs for Cyprus confirmed around 7:45 a.m. ET that all of the passengers and crew had been safely freed.

The drama unfolded aboard EgyptAir Flight MS181, which was on a domestic flight en route from Alexandria to Cairo.

A hijacker who claimed to have an explosive belt ordered the plane to diverted to either Turkey or Cyprus, according to officials. The belt was later deemed a fake.

Related: A Look Back at Historic Hijackings

The Airbus A320 flew to the Cypriot port city of Larnaca and landed at around 7:50 a.m. local time (12:50 a.m. ET) at which point negotiations got underway, EgyptAir said.

The majority of the passengers were soon released, with just four foreigners and seven crew members, including the pilot, left on board.

The hijacker spent the first three hours of the standoff demanding to speak to his Cypriot ex-wife or give her a letter, Cyprus government spokesman Nikos Christodoulides told NBC News.

"Our people — they were talking to him all the time in order to keep him busy and allow people to come out," Christodoulides said, adding that negotiators asked for more hostages be released in return for each of his requests.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The hijacker — who was identified by the Cyprus Ministry of Foreign Affairs as Seif Eldin Mustafa — then shifted his demands.

"He asked for asylum, he wanted to talk with someone from the European Union ... It seems that he was an unstable personality," the spokesman explained.

Live footage from the scene shortly before the arrest was announced showed the pilot dangling from a rope out of the cockpit window and dropping to the ground. Two people were later seen coming down stairs parked next to the jet.

Christodoulides said that once the passengers and crew had been freed the hijacker — in his early 50s — was alone in the plane "so he didn’t have any other option than to come out."

There were conflicting reports about how many people were on board — with some officials saying it was carrying 55 and others suggesting that figure was 81.

The passenger list included eight Americans, according to Egypt's Civil Aviation Ministry.

GALLERY: Hijacker Diverts Jet, Seizes Hostages

It appears that the "explosive" belt the hijacker claimed to have was a fake, Christodoulides said.

Egypt's Civil Aviation Authority also said the belt turned out to be fake, citing Cypriot officials.

The president of Egypt praised Cypriot authorities for "their swift and professional response" — a sentiment coupled with relief expressed by others following the bloodless end of the standoff.

Our appreciation to all who helped to bring this to a peaceful end. 2/2 — U.S. Embassy Cyprus (@USEmbassyCyprus) March 29, 2016

A government source suggested early on that the hijacker's motive seemed to be about a "personal" matter involving a woman. The hijacker is believed to be an Egyptian national.

Cypriot President Nicos Anastasiades, too, said the hijacking was "not something that has to do with terrorism."

When asked by reporters if he could confirm reports that the incident had something to do with a woman, he chuckled "always, there is a woman."

Egypt's Minister of Civil Aviation Sherif Fathy Ateyya defended his country's airport security at a press briefing during the seven-hour hostage ordeal.

The country's Interior Ministry later released surveillance video purporting to show the hijacker going through security.

Tuesday's hijacking put Egyptian aviation security back under scrutiny, coming less than a year after a Russian passenger jet crashed after taking off from the country's Sharm el-Sheikh airport in October.

ISIS claimed responsibility for downing the Metrojet plane and the tragedy raised questions about how any potential explosives may have made it on board and whether there were security failings on Egypt's end.

EgyptAir’s last hijacking was 30 years ago when an Athens-to-Cairo flight was seized by terrorists and diverted to Malta. When negotiations failed, Egyptian troops stormed the aircraft but the hijackers fought back with hand grenades. Sixty of the 90 passengers were killed.