Shortly before a gunman opened fire outside a Walmart in El Paso, Texas, killing 20 people and injured dozens more, a manifesto believed to be linked to him was posted online. It railed against a "Hispanic invasion" and laid out a plan to divide the United States into territories based on race.

Authorities believe 21-year-old Patrick Crusius wrote the document, though they are still gathering evidence.

It begins by praising the manifesto of the gunman who killed 51 Muslims at two mosques in New Zealand earlier this year. That document cited a white supremacist theory known as "The Great Replacement," which postulates that a secret group of elites is working to destroy the white race by replacing them with immigrants and refugees.

"This attack is a response to the Hispanic invasion of Texas," the manifesto says.

The 2,300-word manifesto is divided into five sections: political reasons for the attack, economic reasons, equipment that will be used to carry out the shooting, the expected reaction to the attack, and "personal reasons and thoughts." Titled "The Inconvenient Truth," the document is a jumble of positions and ideologies. In it, the writer warns of the dangers of environmental degradation, rails against corporate influence in the government and cautions against interracial marriage.

Under "political reasons," the manifesto lambastes both Democrats and Republicans, suggesting the United States will soon become a one-party state run by Democrats because of the growing Hispanic population, the death of the baby-boom generation and the "anti-immigrant rhetoric of the right." The author postulates that the growing Hispanic population in Texas will soon make it a solidly Democratic state, which he argues would all but assure repeated Democratic presidential victories.

"The Democrat party will own America and they know it. They have already begun the transition by pandering heavily to the Hispanic voting bloc in the 1st Democratic Debate," the manifesto says.

The document repeatedly rails against corporations, which the author says have taken over the government. The author criticizes Republicans for favoring corporations, but argues that "at least with Republicans, the process of mass immigration and citizenship can be greatly reduced."

The author also expresses fear over the impact automation will have on job opportunities and argues that immigrants should not be allowed to continue coming into the country as long as job opportunities are scarce. He argues that while immigrants often take menial jobs that Americans are unwilling to perform, their children seek better opportunities and often receive college degrees that allow them to obtain high-skill positions. The document again blames corporations for advocating for work visas for skilled workers and says that they rely on immigrants to fill low-skill labor positions.

In a jumbled rant, the document also rails against corporations for destroying the environment by over-harvesting resources. The manifesto chastises the government for being unwilling to confront environmental issues and most Americans for being unwilling to change their lifestyles to be more environmentally friendly. It argues that the United States therefore needs fewer people consuming resources such as water, paper towels and land.

The author wrote that he planned to mainly rely on an AK-47 as his weapon for the shooting, noting that it overheats after about 100 rounds and that he would need a heat-resistant glove.

The manifesto notes that many migrants return to their home countries to reunite with family, arguing that "the Hispanic population is willing to return to their home countries if given the right incentive. An incentive that myself and many other patriotic Americans will provide." The author writes that such terrorist attacks will "remove the threat of the Hispanic voting bloc."

The author ends the manifesto with "personal reasons and thoughts," and says that he has spent his life preparing for a future that does not exist, though does not specify what that future would be. He ends on an anti-immigrant screed, worrying that Hispanics will take over the Texas government and says that he has been given the rights - presumably referring to loose U.S. gun laws and the right to bear arms - to save the country from destruction.

"Our European comrades don't have the gun rights needed to repel the millions of invaders that plaque (sic) their country. They have no choice but to sit by and watch their countries burn," the manifesto says.

Finally, the manifesto ends by decrying interracial couples and proposes separating the United States into territories based on race. The author points to white supremacist theories that "stronger and/or more appealing cultures overtake weaker and/or undesirable ones."

The author expresses fear that he will be captured, rather than die during the shooting, because that would mean he would receive the death penalty and his family would despise him. And he stresses that he has maintained his white supremacist ideology for many years, predating President Donald Trump and his 2016 campaign, which he says did not influence his reasons for carrying out the attack.

"This is just the beginning of the fight for America and Europe," the author writes.

(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)