Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:23:7

But whoever seeks beyond that, then those are the transgressors -  

But whoever seeks ˹anything˺ beyond that, ˹intercourse with˺ wives and concubines, such as masturbation: those, they are transgressors, who have overstepped ˹the bounds˺ into what is not lawful for them.
القرآن:٢٣:٧

فَمَنِ ابْتَغَىٰ وَرَاءَ ذَٰلِكَ فَأُولَٰئِكَ هُمُ الْعَادُونَ  

{فمن ابتغى وراء ذلك} من الزوجات والسراري كالاستمناء باليد في إتيانهنَّ {فأولئك هم العادون} المتجاوزون إلى ما لا يحل لهم.

See similar narrations below:

Collected by Qurʾān
quran:3:82

And whoever turned away after that - they were the defiantly disobedient.  

Then whoever turns his back, in rejection, after that, covenant, they are the wicked.
القرآن:٣:٨٢

فَمَنْ تَوَلَّىٰ بَعْدَ ذَٰلِكَ فَأُولَٰئِكَ هُمُ الْفَاسِقُونَ  

{فمن تولَّى} أعرض {بعد ذلك} الميثاق {فأولئك هم الفاسقون}.
quran:70:31

But whoever seeks beyond that, then they are the transgressors -  

but whoever seeks beyond that, those are the infringers, who transgress ˹the bounds of˺ what is lawful ˹stepping˺ into what is unlawful;
القرآن:٧٠:٣١

فَمَنِ ابْتَغَىٰ وَرَاءَ ذَٰلِكَ فَأُولَٰئِكَ هُمُ الْعَادُونَ  

{فمن ابتغى وراء ذلك فأولئك هم العادون} المتجاوزون الحلال إلى الحرام.