Resignation comes two days after Egypt's foreign minister condemned remarks by Madani that appeared to mock Egyptian President Abdel Fattah al-Sisi
The Saudi secretary-general of the Organisation of Islamic Cooperation (OIC) resigned on Monday for health reasons, according to a statement from the organisation.
Iyad Madani, 70, had held the post since 2012. A statement by the IOC said Saudi Arabia had nominated Yusuf al-Othaimeen, a former minister of social affairs, as his replacement.
The resignation comes two days after Egypt's foreign minister condemned remarks by Madani that appeared to mock Egyptian President Abdel Fattah al-Sisi.
In a statement late on Monday, Egypt's foreign ministry welcomed Saudi's nomination of Othaimeen. It said it would back him in "recognition of the important role played by Saudi Arabia in support of the activities and objectives of the Organization of Islamic Cooperation".
Madani had told Tunisia's president last week "I am sure your fridge has more than water", an apparent jibe at Sisi, who told a youth conference in October that for a decade his fridge contained nothing but water, seen as a message to Egyptians to bear harsh economic conditions.
Egypt said after the incident that it would be "reviewing its position toward the secretariat of the organization".
Madani said his remarks "were only based on a sense of humour and were by no means intended to be offensive to the Egyptian leadership", according to the English-language Saudi daily Arab News.
The OIC has 57 member states and aims "to safeguard the interests of the Muslim world" and preserve Islamic social and economic values, according to its website.
In 2012 the IOC suspended Syria's membership on the grounds of President Bashar al-Assad's suppression of the Syrian revolt.