Answer
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
Hugging your wife while fasting is permissible but you should avoid it as it may lead to further actions which nullify the fast, such as sexual intercourse. As for hugging non-mahram individuals, it is not permitted in Islam, regardless of fasting.
In responding to your question, Sheikh Ahmad Kutty, a senior lecturer and an Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, states:
If you are speaking about hugging your wife while fasting, it is permissible but you should avoid it.
Aishah, the beloved wife of the Prophet (peace be upon him) was asked whether one is allowed to kiss his wife while fasting? She said, โno,โ then when someone pointed out to her, โDidnโt the Prophet kiss you while he was fasting?โ, She replied, โWho among you can restrain himself as the Prophet was able to?โ (Ibn Hibban)
In other words, we should avoid such actions to save ourselves from breaking our fast.
I do not see any difference between hugging and kissing; it is likely to arouse desire, and therefore should be avoided unless someone knows that he can control himself.
As for hugging the members of the opposite sex โ who are not related to you in blood or marriageโ, one ought to avoid it in all circumstances.
Almighty Allah knows best.