Let's take the 'keep it simple' approach... the girl was going through some tough times... you were offering comfort... and your friends steps in and sees this. It's not like you were naked and giving her thrills.
Your friend needs to keep this in perspective... you're a nice guy and couldn't stand to see her cry and wanted to offer comfort... that's it. If he wants her back, then he needs to man-up and go get her. If not, then he needs to ditch these jealous feelings.
All you can do is stay away from this girl - until your friend gets a hold of his feelings for her. (or you can always lose a friend and go for the girl).
In either case.... this is your friend's problem... and he's the one that needs to sort out his feelings. You just got caught up in it as an innocent bystander. Keeping your distance from the girl is the best thing you can do right now.
"The weakest soul, knowing its own weakness, and believing this truth that strength can only be developed by effort and practice, will, thus believing, at once begin to exert itself, and, adding effort to effort, patience to patience, and strength to strength, will never cease to develop, and will at last grow divinely strong."
- James Allen