عَنِ ابْنِ عُمَرَ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «لَا تَمْنَعُوا نِسَاءَكُمُ الْمَسَاجِدَ وَبُيُوتُهُنَّ خَيْرٌ لَهُنَّ» . رَوَاهُ أَبُو دَاوُدَ
Translation

‘Abdallah b. Arqam said he heard God’s Messenger say, “When the time for prayer comes and one of you needs to relieve himself, he should do that first.” Tirmidhi transmitted it, and Malik, Abu Dawud and Nasa’i transmitted something similar.