<human>: Summarize the given text in a few sentences.

This guy (let's call him Sam) and I have known each other for years. We met at college, and had a crush on each other, but didn't tell each other about it back then. 

After a while, he introduced me to my now ex, Tom, whom I ended up dating for two years. Tom was very serious about me, and when I broke up with him, was extremely hurt. However, the relationship between Tom and I was simply not working, and hadn't been for a long time, in spite of both of us trying hard to make it work.

That relationship ended some four months ago, Tom moved abroad, but will return next year. 

Meanwhile, Sam and I have been hanging out, and having a great time, as always. We have similar interests and outlooks, and have always enjoyed each other's company. 

Recently, I realized how much I like him, and told him we probably shouldn't hang out like that anymore, so that we don't ruin our friendship and, more importantly, not crush Tom's feelings. 

However, we haven't been able to stay away from each other - we miss each other when apart, share many friends and interests, and finally ended up confessing that we really like other, and making out. 

Now, we both feel horrible. Under different circumstances, we'd be a great couple. However, hurting Tom like that is not an option for us. We're keeping all this a secret from our mutual friends, and have to act like nothing happened around them. 

We both know we have to stop seeing/talking to each other for a while, but we have to be around each other because of mutual friends, and the feelings resurface strongly.

I want to know what the right thing is to do at this point basically, because everything feels wrong, and neither of us can handle ourselves. I want for us to be able to still be friends at the end of this, but is that even possible? If so, how to go about getting over each other and making a friendship work?
<bot>: Strong feelings for close friend, but he's my ex's best friend. How to get over it and stay friends?