Office politics are fraught with difficulty. Almost nobody likes dealing with office politics, and it’s the people who do enjoy it that you have to worry about.

And just like regular politics, office politics is an unavoidable element of human behavior—bring people together and the jockeying begins.

A lot of the advice about how to handle office politics boils down to “just don’t play,” as if avoiding the political system in your office will protect you and your career.

It won’t.

Saying you’re not affected by office politics is like saying you’re not affected by politics at large. It makes a difference, even if you close your eyes and hope it goes away.

Related: 5 Ways to Respond to Negative, Evil Emails

The key to winning at office politics is to stop wishing it will go away and to start learning how to thrive in your workplace’s political environment. You don’t have to dive right into the seedy underbelly of office politics to win the game; you win by playing smart and knowing when and how it’s worth getting involved.

1. Learn the lay of the land.

Whether you just started a new job or just realized that avoiding office politics is detrimental to your career, you have to begin by figuring out exactly what’s going on. Your office is full of allies and rivals, and, if you watch and listen closely, you can get a pretty good sense of who’s aligned with whom:

  • Who has lunch together?
  • Who gets invited to important meetings, and who doesn’t?
  • Who always seems to be the first to know about coming changes, and who always seems to be last to know?
  • What are the cultural hot buttons that get tempers boiling?

The answers to these questions define your political landscape. This doesn’t mean that you should choose a side—that would be counterproductive—but it’s smart to understand the rules and the players and their strategies before you jump into the fray. Otherwise, you could find yourself unintentionally caught up in a long, simmering rivalry.

2. Build broad alliances.

One of the smartest things you can do is to build alliances throughout the company so that you’ll have a foot in as many of the political camps as possible. If you accomplish this and show people across the board that they can rely on you, you’ll stand a good chance of coming out ahead, no matter which political camp is currently “winning.” You also won’t be left out of the cold if a group of allies leaves the company.

3. Keep your eyes on the goal.

Remind yourself, as many times as it takes, that you’re not engaging in office politics for fun or to be one of “them;” you’re doing it for two reasons: career success and job fulfillment. When you get caught up emotionally, you run the risk of making decisions you’ll regret down the road. Gossiping, backstabbing, manipulating, and the rest are not needed to win at office politics. Keeping your eyes on the goal lets you develop and maintain a strategic approach for dealing with your workplace’s unique political atmosphere.

Related: 9 Things Successful People Won't Do

4. Keep things win-win.

You’ll also need to keep things win-win. Part of what gives office politics such a bad reputation is the perception that there’s always a winner and a loser and that you only win if your opponent limps off the battlefield, bloody and bruised. But, done correctly, this isn’t a zero-sum game. Navigating office politics works best when you follow the golden rule of negotiating: end with everybody feeling like they won. Instead of trying to defeat an opponent, spend that time and energy thinking about how you can both get what you want. This is how you play the game smart.

5. Never pit rivals against one another.

One situation that everybody dreads is getting caught between two warring parties. In a situation like that, it’s easy to tell each of them what they want to hear, even if that’s just nodding in agreement when they bad-mouth each other. But fake allegiances are always exposed in the long run, and then, neither of the people you were trying to impress will trust you again. Instead, steer your conversations back to the facts: What decisions need to be made? What are the next steps? What can I do to help improve this situation?

6. Stick to your principles.

Finally, you must stick to your principles, without fail. Before taking any action that’s fueled by office politics, ask yourself why you’re doing it. If you’re motivated by fear, revenge, or jealousy, don’t do it. If it conflicts with your values and beliefs about fair behavior, it’s better not to get involved.

Bringing it all together

Deciding to stay out of office politics altogether isn’t an effective strategy. As long as it’s going on around you, you’re going to be affected by it. It’s a lot better to be a competent, conscious player than to be a bystander or a pawn in the game.

The key is to understand the players and the rules and then to play the game in a way that aligns with your personal values and principles. Don’t be fooled into compromising “just this once,” because once is all it takes to lose control.

A version of this article first appeared at TalentSmart.com.

Related: How Successful People Stay Calm