In Islam, I know that loving God and His Messenger (peace and blessings be upon him) is an obligation, but what is the ruling for having feelings towards someone else of the opposite sex? And what are the limits in this case?
A Muslim is not blameworthy for the chaste involuntarily love and the mere good feelings he/she has towards another person of the opposite sex. Love is one of the most sublime feelings that all beings share. The Prophet (peace and blessings be upon him) used to described his love to his beloved wife lady Khadija (peace be upon her) as “I was nourished by her love”.
However, it is forbidden for a Muslim before marriage to follow it up with prohibited actions either by words or deeds. The Prophet (peace and blessings be upon him) said, “Whoever falls in love, preserves his chastity, suppresses his feelings, and dies, is a martyr.”
The unlawful relationship that one inflames through immoral words or actions is deemed unlawful [haram] in Islamic law, and it is impermissible for a man and a woman to have a relationship outside marriage.
The love of God the Almighty and His Messenger is incomparable to any other love because they occupy different status.
God the Almighty knows best.