Ibn Abbas commented on the verse "Do not be too loud in your prayer, nor too quiet in it" [Isra 17:110]. He said that it was revealed while the Messenger of Allah ﷺ was in hiding in Makkah. Whenever he raised his voice, the idolaters would hear him and would insult the Quran, the One who revealed it, and the one who brought it. So Allah Almighty said, "Do not be too loud in your prayer, nor too quiet in it" [Isra 17:110]."Do not be too loud in your prayer" means, so that the idolaters hear you. "Nor too quiet in it" means, from your companions, so that they cannot hear you. "But seek a way between that" means, let them hear you, but do not raise your voice, so that they may learn the Quran from you.
حدثنا مسدد عن هشيم عن أبي بشر
عن ابن عباس رضي الله عنهما {ولا تجهر بصلاتك ولا تخافت بها} قال أنزلت ورسول الله ﷺ متوار بمكة فكان إذا رفع صوته سمع المشركون فسبوا القرآن ومن أنزله ومن جاء به فقال الله تعالى {ولا تجهر بصلاتك ولا تخافت بها} {لا تجهر بصلاتك} حتى يسمع المشركون {ولا تخافت بها} عن أصحابك فلا تسمعهم {وابتغ بين ذلك سبيلا} أسمعهم ولا تجهر حتى يأخذوا عنك القرآن