just let your friend know who it is. if it is the same girl tell him that you arent going to lose to him! tell him that if the girl starts to become between your friendship then you will decide to back off. if you do back off and you end up losing the girl and the friend, well, he wasnt your friend to begin with. if you lose the girl but keep the friendship and you remain friends, well, you are a good man and he will respect you for that. if you gain the girl and he gets butthurt and doesnt want to be your friend, well, those are not good friends to have. if you gain the girl and he remains your friend, that is a good respectable man to have as your friend.
basically tell your friends boys before toys. probably since you are asking this advice, you are in your youth. the friendships you make now sometimes can be the most dependable people to have in your life. i have about 5 friends who i can truly say would take a bullet for me, and i'd do the same for them. but all the girls came and went, but in the end we all ended up happy. it is ok to be rivals too, much like you 2 are probably cubing rivals. the competition makes your friendship stronger.