MEXICO CITY, Mexico — The five teenage boys slump against the wall of a dark house and eye the camcorder nervously. Suddenly, a fist enters the frame smacking one of the boys in the face. Then the barrel of an automatic rifle appears and the teenagers’ expressions turn to terror.

“Why are you here?” shouts a voice.

“For robbing,” one of the boys mumbles.

“You see. You were little rats and now look at you,” replies the interrogator.

The torture video of the five alleged house burglars was posted on the internet last week. It is the latest sign of brutal vigilante justice spreading across Mexico.

As kidnappings, muggings and car jackings spiral out of control, and the authorities appear increasingly impotent, shadowy groups have been advocating justice by the sword.

In other recent cases, alleged kidnappers and car thieves have been abducted and murdered and had their corpses dumped in public places along with threatening notes.

There are also rising cases of mobs lynching alleged thieves and leaving them beaten, naked and tied up.

“The government is failing to provide security and people are turning to some brutal alternatives,” said Rossana Reguillo, who studies crime and violence at the Jesuit University of Guadalajara. “This is not something that has always been around in Mexico. It is a new phenomenon that has been growing since 2000.”

In the latest case, the five teenagers were abducted after they allegedly robbed a house in the town of Tepic in the Pacific state of Nayarit.

The boys — all students of a local high school — were taken to an abandoned building where they had their heads shaved and then were beaten by fists and rifle butts and threatened at gun point, as shown on the video. One of the torturers is heard on the film saying he is the man whose house was robbed.

The teenagers were also forced to perform sexual acts — including kissing each other in front of the camera — as a humiliation. The gunmen are heard threatening to cut their hands off unless they comply.

After being held all night the students were dumped naked on the street and then attended at hospital for injuries including broken ribs.

The torture film was posted on YouTube under the title “Little Rats of Tepic.” YouTube’s monitors quickly removed it from the site, flagging it as unsuitable content.

Following an outcry over the film, police on Monday arrested four building workers for the torture.

However, one of the boys said they had first been arrested by state police and it was the officers themselves who turned them to the vigilantes. The Nayarit police chief denies the charge, saying officers did not question the boys until after they had been tortured.

The incident sparked disgust and condemnation from many.

“Opening the door to justice by your own hand is an enormous step back to a state of barbarism and lack of culture,” said Huicot Rivas, the president of Nayarit’s Human Rights Commission. “In a democratic state, crime can never be used to combat crime.”

However, others cheered on the vigilantes for trying to clean up the streets.

“For me the men who made this video are heroes. I sincerely admire them,” wrote a reader on the website of Mexican newspaper El Universal. “In Mexico, we need death squads to hunt and exterminate rats and kidnappers without further expense to society and the without human rights people getting in the way.”

“I recognize that this is not the correct way to administer justice but I can’t deny that it makes me happy that this type of thing happens,” wrote another reader.

Such feelings reflect desperation among many in Mexico about the lack of security. Amid a drug war that has left thousands dead, rates of anti-social crimes such as kidnapping and carjacking have risen to become among the worst in the world. At the same time, conviction rates for these relatively minor crimes are as low as 5 percent.

Many readers of newspapers have also written in to commend shadowy vigilante groups that have publicly announced their appearance in crime-plagued communities.

One such group called the Popular Anti-Drugs Army materialized among farming towns in the southern state of Guerrero.

Displaying blankets with written messages on bridges and buildings, the group claimed to be made up of family men who had come together to force drug dealers off the street.

“We invite the people to join our struggle and defend our children who are the future of Mexico,” it said on one of the blankets.

The group has been linked to several killings, including the decapitation of an alleged drug dealer in December.

Following stories of that slaying, readers hailed the efforts in some Mexican media outlets.

“My sincerest congratulations to these brave men with their courage and determination,” wrote a reader of Mexican newspaper Milenio. “God help them with their noble cause.”

Investigators suspect that organized-crime groups themselves could be behind many of the vigilantes. While the gangsters traffic drugs to the United States, some are against selling them in their own communities and are opposed to criminals such as muggers and kidnappers.

A similar situation emerged in Colombia in the 1990s, when paramilitary groups both trafficked drugs and enforced the law against petty crooks in the fiefdoms they controlled.

The investigator Reguillo says that while it may not get as bad as Colombia, the vigilantism does pose a real threat to the Mexican state.

“When armed groups administer their own justice, this represents an alternate power,” she said. “This a major problem for democracy in Mexico.”