Is making an agreement that resembles gambling, even if technically avoiding the explicit definition of Qimar (gambling), permissible?

Chapter on Riba (Usury) and Exchange (Sarf)

Al-Mughni

Book of Sales

Book 12 · Issue 3 · Bab 3

Open in Qurani

Primary text

An action resembling Qimar is forbidden, even if it enters a technical loophole. The narration concerning the Prophet, peace be upon him, stated that whoever places a horse between two horses, being certain it will win, it is Qimar, but if uncertain, it is not Qimar. This indicates that entering a form intended to legalize the forbidden, while technically outside the strict definition, is still forbidden, as it does not negate the essence of the prohibited act, which is being either the taker or the taken from in a wager. All such devices fall under this prohibition.