In the movie Avatar, it turns out that all of the trees on the planet are joined in a massive godlike hivemind called Eywa - who is conincidentally the Na'vi God. So, Eywa is a planetary brain made out of all the trees of the world. That alone is quite amazing, but not divine.
Okay, so all Pandoran life hooks into her, but only plants are wired to her network full-time. Eywa liked being worshiped as a goddess and chose to use her control of the world's more primitive animals to keep the Na'vi locked in scientific and technological stasis so that they would never advance far enough in science to study her true nature and blow the whole thing. After all, when she provides them what they need, why would they advance?
Her plans hit a snag when humans came to Pandora. Here was a sentient species with technology to reach the stars and the science to figure out what she really is. These people obviously had to be gotten rid of before they could spill the big secret to the Na'vi. But she had to do it in such a way that no curious Na'vi would consider talking to or learning from the humans should they return, which ruled out a simple Zerg Rush of wildlife (which would also have risked the humans attacking from orbit).
She finds out that they are here for the Unobtanium, which is the perfect source for the conflict she needs. Eywa, in her role as Na'vi goddess, tells her people to be as uncooperative as possible. She has them spurn all offers of technology or science, and tells them to ignore the desperate need the humans have for the stuff that they're sitting on. As per her orders, some engage in low-level guerrilla warfare (such as the arrows on the truck tires). They expel the school from their village, which raises tension.
When Jake Sully arrive on the planet and becomes an Avatar, she senses in him someone bitter with humanity and fascinated by the lushness of Pandora. As a bonus, he is not a scientist. She decides that these things make him valuable as a pawn, which is why she called off Neytiri's attacking him and orders him let into the Hometree. She has him bond with animals of Pandora, perhaps subtly messing with his brain via her control of them, until he comes to feel more Na'vi than human. This has the bonus effect of distracting him from his diplomatic mission.
She needs atrocities to be sure that the Na'vi remain anti-human and anti-science. She allows the destruction of the Hometree in order to galvanize the anti-human sentiments of both her pawn Jake and the Na'vi. The naive chumps make it even easier for her by bringing her Dr. Grace to heal. Grace is the top scientist on the planet, who had been actively hunting her secret and who would have loved to reveal it if she found it; that would have caused Eywa's whole charade to crumble. And she gets to "heal" her? Perfect! As a bonus, Grace was shot by a human, so Jake's anti-human sentiments were raised even further. Dr. Grace took wounds in the chest, which shouldn't affect her mind — but they do give Eywa the perfect excuse after she absorbs the poor woman's mind. "Her wounds were too great"? Likely story. She was still alive, and her mind was intact. Nothing stopped the transfer but the fact that she would be far more useful to Eywa dead than alive. Also, to be sure that Jake further reveres her, she has Grace's hollow shell say, "I'm with her, Jake. She's real." A planetary brain that can control thousands of animals at once can control one more body (even a human one) for a minute.
Then, to ensure that all the tribes of Na'vi remember the humans only as bringers of death, she gave Jake the Toruk to gain power over them. He led them into battle, where the humans' superior technology easily slaughters them. Eywa wanted this. She needed plenty of death to get the Na'vi to hate and distrust humans forever after. A
fter she judged the slaughter to be sufficient, she commanded her mindless herd of slave-beasts to charge and overwhelm the humans. She could have done that at any time.
After that, she has the Na'vi "escort" the humans offworld. Note her insidious effect on her pawn Jake Sully: by then, he referred to his own species as "aliens". Then she transferred Jake Sully's mind to his avatar form permanently, probably performing any remaining necessary mind rearranging as well.
The plan worked like a charm. The humans are gone. The Na'vi are led by a firmly anti-human leader who deifies her. The Navi are embittered towards the humans. There is no more risk of the Navi realizing that they've been played for fools. That's right, the true villain won. You just didn't see it.
(This is an edit of a Fan Theory which blew my mind.)