The hate-filled Texan charged with slaughtering 22 people at an El Paso Walmart admitted he was targeting “Mexicans” when he surrendered to police, authorities said.

“I’m the shooter,” Patrick Crusius told officers as he got out of a Honda Civic stopped at an intersection shortly after last Saturday’s border-town massacre, El Paso Police Detective Adrian Garcia wrote in an arrest warrant ­affidavit.

Crusius, 21, stepped out of the car “with his hands raised in the air” and surrendered, Garcia wrote in the affidavit, obtained by The Washington Post.

“The defendant stated once inside the store he opened fire using his AK-47 shooting multiple innocent victims,” Garcia wrote. “The defendant stated his target were ‘Mexicans.’ ”

Eight of the 22 victims were Mexican citizens, officials in Mexico said. Most of those murdered had Hispanic last names.

Garcia said 19 shooting victims died at the store and the other three died later as a result of their wounds.

Crusius waived his right to an attorney and agreed to speak with police, telling them that he drove 10 to 11 hours from his home in Allen, Texas, with an assault rifle and multiple magazines, Garcia wrote.

Crusius is believed to be the author of an online rant posted before the shooting that complained about the “Hispanic invasion of Texas.”

“I am simply defending my country from cultural and ethnic replacement brought on by an invasion,” the rant reads.

“Main gun: AK47,” it said. “Gear.”

“In short, America is rotting from the inside out, and peaceful means to stop this seem to be nearly impossible,” the screed’s author wrote.

Chris Ayers, an attorney for the Crusius family, said relatives had never heard him use anti-immigrant or racist language. Ayers did not immediately return a call from The Post.

Crusius has been charged with capital murder, and El Paso District Attorney James Esparza said he would seek the death penalty.

Crusius is being held without bond.

El Paso police officials said the feds, who have been investigating the incident as a hate crime and an act of domestic terror, also will file charges.

The El Paso massacre came hours before a mass shooting in Dayton, Ohio, where nine people were killed in the city’s nightlife district.

Meanwhile, families on both sides of the US-Mexico border have been gathering to bury their loved ones.

A service for Alexander Hoffmann Roth, 66, was held on Friday in Ciudad Juarez, Mexico.

“It’s an incredible binational place. I’ve had so many good memories in this area from Juarez and El Paso . . . the people, the food, the music, the ambiance, everything, everything is so warm,” Hoffmann Roth’s daughter, Elise Hoffmann-Taus, said. “And this, this really hurts.”

Juan Velazquez, 77, was laid to rest on Friday in El Paso. He and his wife, Nicholasa Velazquez, were shot after parking their car at the Walmart. She was injured and he died Monday.

A service for 15-year-old Javier Amir Rodriguez is scheduled for Saturday at an El Paso church.

With Wire services