Abdullah bin Abbas reported,

A woman who had lost her sanity and had committed adultery was brought before Umar. He consulted some people about her, then ordered that she be stoned. As she was being taken away, she was led past Ali bin Abu Talib, may Allah be pleased with him.Ali asked, "What is the matter with this woman?"They replied, "She is the insane woman of such-and-such tribe. She committed adultery, and Umar has ordered that she be stoned."Ali said, "Take her back."Then he went to Umar and said, "Commander of the Believers, do you not know that the pen has been lifted from three: from the insane person until he recovers, from the sleeper until he wakes, and from the child until he reaches the age of reason?"Umar said, "Yes, indeed."Ali said, "Then why is this woman being stoned?"Umar replied, "For no reason."Ali said, "Then release her."So Umar released her, and he began to say, "Allahu Akbar."

Abu Dawud 4399

Daif

حدثنا عثمان بن أبي شيبة حدثنا جرير عن الأعمش عن أبي ظبيان

عن ابن عباس قال

أتي عمر بمجنونة قد زنت فاستشار فيها أناسا فأمر بها عمر أن ترجم مر بها على علي بن أبي طالب رضوان الله عليه فقال ما شأن هذه قالوا مجنونة بني فلان زنت فأمر بها عمر أن ترجم قال فقال ارجعوا بها ثم أتاه فقال يا أمير المؤمنين أما علمت أن القلم قد رفع عن ثلاثة عن المجنون حتى يبرأ وعن النائم حتى يستيقظ وعن الصبي حتى يعقل قال بلى قال فما بال هذه ترجم قال لا شيء قال فأرسلها قال فأرسلها قال فجعل يكبر

أبو داود 4399ضعيف
Contents
Reference
Commentary
Ayat
Collection
Sunan Abu Dawud
Book
Legal punishments
Chapter
Insane person who steals or commits a crime deserving a hadd punishment
Numbering
Darussalam 4399
Abu Dawud 4399