The Messenger of Allah ﷺ said, "Do not prevent the female servants of Allah from praying in the mosque."A son of his said, "But we do prevent them."He became extremely angry and said, "I tell you something from the Messenger of Allah ﷺ and you say, 'We prevent them'?"
حدثنا محمد بن يحيى النيسابوري حدثنا عبد الرزاق أنبأنا معمر عن الزهري عن سالم
أن رسول الله ﷺ قال لا تمنعوا إماء الله أن يصلين في المسجد فقال ابن له إنا لنمنعهن فغضب غضبا شديدا وقال أحدثك عن رسول الله ﷺ تقول إنا لنمنعهن
Bukhari narrated it in the Book of Adhan, Chapter on a Woman Seeking Her Husband's Permission... etc., hadith no. 873, from the hadith of Maamar, in a shortened form. Muslim also narrated it, hadith no. 442/135, from the hadith of Ibn Shihab Zuhri, with a similar meaning.