Sayyiduna Anas bin Malik (may Allah be pleased with him) said: A man said to the Prophet (peace and blessings be upon him): I hear the saying of Allah, the Lord of Might: "Divorce is twice" [Surah al-Baqarah: 229]; where is the third divorce? He said: "'Then either retain her in a fair manner or release her with kindness' [Surah al-Baqarah: 229]; this is the third divorce."
This is how it was reported from Sayyiduna Anas (may Allah be pleased with him); the correct version is from Isma'il bin Sumay' from Abu Razin from the Prophet (peace and blessings be upon him) as mursal (without mention of a Companion), and a group of trustworthy narrators narrated it from Isma'il in that way.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الخلع والطلاق / 14991