There’s no doubt that being passed up for a job you wanted is a terrible thing. But even worse than that? Meeting the person who got the position you were gunning for.

Maybe you spot him at a networking event, or you work in an industry small enough to know all the important names. She might have even been a colleague you’ve worked with for years.

If and when you find yourself in this awkward situation, it can be tempting to drop everything and flee. After all, your wounds are still fresh, and the last thing you’d rationally want to do is be cordial to the person who stole your dream job right out from under you.

Thankfully, Muse columnist Jaclyn Westlake and Muse career coach Lauren Laitin have sound advice for this exact problem. Instead of trying for a Bond-style escape route every time you bump into this person, you can handle it professionally.

First off, you should know that the job search process is a grueling one for everyone, so that sour taste in your mouth is natural. Before you do anything, remember it’s OK if encountering the new hire feels personal to you. Missing out on something you really wanted sucks, and you’re allowed to feel sad about that.

“You're not going to convince anyone that you're doing just fine if you haven't taken an honest moment to grieve,” explains Westlake. “Losing out on a new opportunity or promotion can shake your confidence and make it even harder to face the person who edged you out.”

So after you give yourself adequate space, jump start the healing process by reminding yourself what made you capable and skilled in the first place. Whatever resolve convinced you that you were qualified enough to go after that position—that’s what you should bring yourself back to. Westlake recommends you “start by making a list of your greatest strengths and most meaningful accomplishments.” Then, if you find that you’re second guessing yourself in your interactions, it’ll be helpful to have that list to refer back to.

From there, you can lay the groundwork to genuinely get along with the person. If it’s about a new job, reach out to him or her. “As in all things, taking the high road is your best bet,” says Laitin. “You never know when a new opportunity at that company might open up, and you might end up being colleagues after all.”

In this specific situation, a short email message will do the trick. “You don't need to gush or be disingenuous, just keep it short and sweet,” explains Westlake. “It can be something as simple as, Hi [name], I just heard the news—congrats on your new job! This serves two purposes: It breaks the ice and sets the tone for the first time you run into each other.”

The simple gesture won’t only position you to be on friendlier terms with a potential contact, but it’ll also pave the way for opportunities down the road as well.

But, maybe it’s not about a new position at a new company, but rather something between you and a colleague—a peer who just became an authority figure. If the situation is about a promotion that you didn’t get but your co-worker did, as difficult as it sounds right now, do your best to be civil.

Westlake says, “Chances are, the person who got the job over you is feeling a bit awkward about the situation too, so taking a moment to let him or her know that there are no hard feelings should make everyone more comfortable.”

And, if you’re willing to take that extra step, you can even ask if there’s anything you can do as that person transitions into the new role. “Better yet, let him know that you had some great ideas for this role and would love to collaborate once he’s had a chance to settle in,” shares Westlake. “Ideally, you'll be able to help him succeed (you're on the same team, after all), and you'll gain valuable experience with the job you wanted.” Seriously, what better info could you add to your resume?

“Regardless, being gracious and cordial is best,” confirms Laitin. “If you can stomach the answers, you might even ask how it's going—you never know what you could learn about the company you were so excited about.”

The common thread here is to try your best to learn from the experience. Being passed up for a job or a promotion can be an extremely difficult thing—and it takes real moxie to dive head first into solving what might have been your problem areas.

You don’t need to be BFFs tomorrow with the person who ended up with the job you wanted, but chances are, you have a lot in common with him or her. On top of a shared passion for and experience in the same industry, you also have similarities in terms of your ambition and ideal company fit. So, it’s not so much of a stretch that you’d be able support one another and exchange notes—as equals rather than as competitors.

Photo of two women talking courtesy of Caiaimage/Tom Merton/Getty Images.