Early man was a total mean girl. —

Gossipy, cliquey, exclusionary — these are some of the traits our human ancestors developed to thrive over the last 6 million years, argues psychology professor William von Hippel in his new book, “The Social Leap” (Harper Wave), out now.

“Nothing is more important to us than our social connections. Nothing was more critical for our ancestors’ survival and reproduction,” von Hippel writes.

Social connection and its middle-school messiness assured our survival — more than harnessing fire or developing opposable thumbs. Von Hippel writes that a series of “social leaps” — or movements forward in the way we connect with our fellow man — made our brains bigger, our connections stronger and our long-term survival certain.

And the real gift to mankind was our bitchiness.

The first major social leap happened around 10 million years ago when our chimp ancestors were forced out of the rainforest and into the grasslands, thanks to tectonic shifts in the East African Rift Valley.

Our great-ape cousins had few social ties and limited group reliance, according to sociologist Jonathan H. Turner of the Evolution Institute. But when our ancestors were sent scurrying into the savannah in search of food, while needing protection from predators, this all changed.

“No doubt many of our would-be ancestors perished, but some of them survived and eventually began to thrive, and their story is our own,” writes von Hippel.

Our story begins with one of the longest living early human species, the Australopithecus afarensis, about 3 million years ago.

Though the Australopithecus look a lot like chimps, they adapted to their new environment by forming more elastic muscles in their hips, shoulders, arms and wrists — perfect for throwing stones.

The Australopithecus figured out quickly that aiming projectiles at saber-toothed tigers alone was not effective. So they began to band together, creating collective stone-throwing groups.

This brought about “the most important psychological change that enabled us to thrive, rather than just survive, on the savannah: the capacity and desire to work together,” writes von Hippel.

The minute early man learned to band together, he also acquired a new weapon: ostracism. If you wanted to be invited to the lion-eating party, you better play by the lion-killing rules.

Offenders who, say, ran away instead of throwing rocks at an incoming predator, would be iced out.

‘Our ancestors rapidly evolved a strong emotional reaction to the threat of being ostracized’

“Fear would have made it awfully tempting to leave the task of protecting the group to others,” writes von Hippel. “Those . . . who ran away at the first sign of danger would soon have found themselves unwelcome in the group, facing dire circumstances and poor reproductive success.”

Repeat offenders would be expelled — to their certain death.

“To be forced out of a group of Australopithecines on the grasslands was a death sentence. For this reason, our ancestors rapidly evolved a strong emotional reaction to the threat of being ostracized,” writes von Hippel.

That strong reaction continues today. “Ostracism and rejection have remained important tools for enforcing cooperation through to the present, and as a result we still find social rejection incredibly painful and do whatever it takes to stay in our group’s good graces,” von Hippel writes.

Sometimes even outright excommunication wasn’t enough, so our ancestors instituted a collective punishment perfect for our new bodies.

“Stoning was probably one of the earliest forms of punishment our ancestors meted out to peers who failed to do their part,” von Hippel writes.

Dealing with all these new — and possibly deadly — social pressures challenged us mentally, leading to yet another social leap called the “social-brain hypothesis,” which argues that primates developed larger brains to deal with the greater complexities of life.

Enter Homo erectus, or “upright man,” 1.8 million years ago, whose big brain enabled him to develop tools and harness fire.

Fire was particularly important to our brain development, writes von Hippel, allowing us to take in more calories by making food more digestible. Meanwhile, fire also gave us the luxury of storytelling.

“Fire enabled us to extend our community time past daylight, without the added risk of predation, and in doing so gave us the unique opportunity for socializing and reflecting, as the work of the day was no longer possible,” writes von Hippel. “Storytelling allows each generation to build on information gathered by their ancestors, as cultures accumulate knowledge about how to deal with their local environment.”

In other words, these fireside chats gave us our first ever gossip session.

At this time, another social leap occurred: our ability to read another human and to attribute and anticipate their thoughts, also known as “Theory of Mind.” (Small children, for example, do not have this capacity. It is typically developed around age 4 or 5. Simon Baron-Cohen, director of the Autism Research Center at Cambridge, believes that people with autism may struggle with Theory of Mind.)

Once we acknowledged that others view the world differently than us, a whole host of new behaviors — some of them pretty ugly — started to emerge.

Among them: feelings of pride, guilt and shame — a whole grab bag of deadly sins. “These are often referred to as self-conscious emotions, as their development requires awareness of how others are appraising us, and they differ from other social emotions, such as anger and love, in that the focus is inward,” writes von Hippel.

These painful emotions of inadequacy are key drivers in keeping everyone in line.

Humiliate a person who fails to bring in enough meat at the hunter-gatherer encampment? He’ll probably never make the same mistake again.

Our ability to lie and deceive also evolved.

Though many members of the animal kingdom use deception, outright lying requires Theory of Mind, as one needs to comprehend what someone is thinking in order to manipulate them. Evolutionary scientists say this is a distinctly human behavior. Chimps, by contrast, may understand “the goals, intentions, perceptions and internal knowledge states of other individuals,” but are unable “to internalize situations in which other individuals have false beliefs,” writes David Barash in his 2012 book “Homo Mysterious.”

But the emergence of self-deception was the ultimate “social weapon,” von Hippel writes.

Lying to yourself has two benefits: “It eliminates the costly cognitive load that is typically associated with deceiving, and it can minimize retribution if the deception is discovered,” according to von Hippel’s 2011 article in Behavioral Science.

For example, if you tell people you’re the greatest hunter in the group but on this occasion you can’t catch anything because of bad weather — and you actually believe it — people are more likely to believe you, too. And then you avoid those pesky emotions of guilt and shame for not stepping up that day.

This kind of ego-inflation is common to all of us. One study showed that if you take a photo of people and then digitally manipulate copies to amplify or detract from their looks, they most often pick one amplified by 20 percent as their real photo.

Armed with hubris, it’s no wonder Homo erectus, with twice as big brains as the Australopithecines, became the first archaic human species to leave Africa and colonize areas in Europe and Asia, plan for the future and develop early forms of language. (Recently, Bentley University global studies professor Daniel Everett argued that Homo erectus even sailed small boating vessels.)

The negative outcome of all this advancement — as Homo erectus gave way to our namesake Homo sapiens around 200,000 years ago — is a modern scourge on every playground in the world: cliques.

We may have become generally nicer to each other (at least since the days of our chimp cousins), but this only increased our hostility for outsiders.

Though it seems obvious to dislike a stranger for threatening our resources, this impulse points to an even deeper underlying fear.

“In a pre-medical world, the threat of disease was much greater than it is today, so we developed psychological adaptations to disease threats,” writes von Hippel. These adaptations are classified as “the behavioral immune system.”

The behavioral immune system acts the same way our bodies do to unwanted viruses or bacteria: by pushing them right back out. “Dislike and fear kept neighbors apart, and once you don’t interact with others anymore, your languages and religions naturally diverge as well. All these processes are self-perpetuating and serve to further group separation,” writes von Hippel.

In other words, tribalism — something we see as rampant in our politics today — is as old as man, and maybe a bit older. “Just because we got smarter doesn’t mean we got any wiser,” writes von Hippel. “For better or worse, we haven’t been able to shake many of our ancient instincts.”