Authorities did not say whether the pair had made any demands.
But one waved a green flag outside the aircraft, suggesting loyalty to the late Libyan leader Moammar Gadhafi
Afriqiyah Airways Flight 8U209 was en route to the Libyan capital of Tripoli with 111 passengers aboard when hijackers diverted the plane.
• All passengers and crew members on board were released. They returned to Libya early Saturday, according to Malta's national security minister, Carmelo Abela.
• The hijackers are being interrogated, Malta's Prime Minister says.
• The weapons they had were replicas, he says.
• Egypt said the hijackers wanted to land in Alexandria.
The flight, an Airbus A320, took off Friday morning from Sabha, a desert city in southwestern Libya. Hijackers forced the plane to divert to Malta, some 350 kilometers (217 miles) from the Libyan coast in the Mediterranean Sea.
After the aircraft landed late Friday morning, the Maltese military led negotiations with hijackers, who threatened to blow up the aircraft with hand grenades, Foreign Ministry spokesman Etienne St. John said.
By early Friday afternoon a group of women was allowed to leave the plane. Later, the remaining passengers and crew left, smiling and chatting as they stepped off the plane and onto the tarmac.
Maltese Prime Minister Joseph Muscat posted details of negotiations in real time on his Twitter account.
The hijackers are probably of Libyan nationality, Muscat told reporters after the standoff ended. The men are in custody and being interrogated, he said. Forensic tests revealed the weapons they had were replicas, Muscat said.
Egypt: We stopped plane from landing here
Before it landed in Malta, the hijacked plane had requested to land at Burj Al-Arab airport in Alexandria, Egypt, the Egyptian Civil Aviation Ministry said in a statement.
The Egyptian government didn't allow the flight to enter its airspace, the ministry said.
As the situation unfolded, several flights to and from Malta International Airport were delayed, and some were diverted to Italy.
Carmen Nistor, who was waiting for a flight to Munich, Germany, said passengers were frustrated because they hadn't been informed about the cause of the delays.
Sabha, the city where the flight began its journey, has been a center of political tribal violence.
Deadly clashes have erupted there between tribes that were loyal to Gadhafi and anti-Gadhafi groups. Enmity runs deep between the Gaddadfa and Suleiman tribes, the most powerful armed factions in the region.
Gadhafi, who was a member of the Gaddadfa tribe and led Libya for more than 40 years, was ousted and assassinated by rebels in 2011 in the Arab Spring uprising.
Libya has struggled to install a stable government since, and the leadership vacuum has allowed militant groups such as ISIS and al Qaeda to flourish.