Egypt has freed the last two Al Jazeera journalists who remained in detention in the North African country following a thaw in relations with Qatar, the Doha-based network said on Friday.

One of the journalists, Bahaa Eldin Ibrahim, had returned home after being freed, his wife Mona Gamal Eldin confirmed. The head of Egypt's journalism syndicate posted a photo on Facebook of the second journalist, Rabie el-Sheikh, at his home.

The journalists, both Egyptian, had been held in pre-trial detention for about four years.

Ties between Egypt and Qatar deteriorated after Egypt's then-army chief Abdel Fattah al-Sisi led the ousting of the Muslim Brotherhood's Mohamed Mursi in 2013, rising to the presidency the following year.

Egypt accused Al Jazeera of being a mouthpiece for the Islamist group, banning the broadcaster and arresting a number of its journalists.

In 2017, Egypt, Saudi Arabia, the United Arab Emirates and Bahrain launched a boycott of Qatar over charges it supported terrorism, an accusation Qatar denied.

An agreement to end the row was struck early in 2021, and Qatar and Egypt have moved quickly to rebuild relations.

The release of Ibrahim and Sheikh follows Egypt's freeing of Al Jazeera journalists Hisham Abdelaziz in May 2023, and Ahmed Al Nagdy in September 2022.

Mona Gamal Eldin told Reuters that she learned of the decision to release her husband on Wednesday. Gamal Eldin, who had not seen her husband since December 2018 and had last spoken to him on the day of his arrest in February 2020, said the decision to free them was unexpected.

"I prayed for his release every day and never lost hope," she said.

(Reporting by Farah Saafan in Cairo and Andrew Mills in Doha; Editing by Aidan Lewis, William Maclean)