am i in the wrong?

one of my guy friends used to like my friend about a year ago and she rejected him. i guess ever since then, things have always been weird between them?? sooo around march me and him were snapchatting and we got onto the topic about sex. and he made a kinda off handed suggestion that we should have sex and that he’s fine losing his virginity to me because he trusts me. soooo i kept that in mind. then in june i was hanging out with my friend who rejected him and i asked her if she likes him and she said no. so a few days later that was when me and him had sex. we agreed not to tell anyone and so far we’ve both kept it between us. i was recently hanging out with my friend a few days ago and we started talking about him and his friends (because we were all close, like we used to hang out in groups and talk 24/7) and she was telling me how during class whenever he’s confused, her friends make jokes like “ayo get your man” and stuff like that. sooo idk. am i wrong for having sex with him? my friend confirmed that she didn’t like him but i still feel weird. i feel like she would be mad if she knew, even though she rejected him.