Oil shale drillers in Texas have had to contend with environmental opposition and soaring costs. A few miles south of the border in Mexico, Angel Torrez and co-workers duck gunfire sprayed from drug traffickers, Bloomberg said June 12.

When gunmen pulled up in April in a makeshift tank and riddled the Hotel Asya with bullets, Torrez dropped to the floor. After the attack, the 21-year-old machine operator for Weatherford International Ltd. (NYSE: WFT) and his crew of about 30 left town under police escort. Ciudad Mier, in the gas-rich region along the Texas border known as the Burgos Basin, had already become a ghost town after most of its inhabitants had fled following years of bloodshed.

“My girlfriend says she doesn’t want me here,” Torrez said as he rested on a bench outside his new hotel a few miles away, dressed in a red boiler suit and work boots.

“I tell her I have to work, there’s no other option.”

Torrez’s predicament reveals the challenge facing Mexico as it attempts to replicate the kind of shale bonanza taking place in Texas. As thousands of troops battle a recent surge of violence by drug traffickers and fuel thieves, lawmakers 450 miles (720 kilometers) away in Mexico City are preparing rules to allow foreign companies to drill for the first time since 1938. Drilling in Mexico would seem a natural next move for the thousands of wildcatters who have brought a boom to Texas, yet until the violence abates, that’s not likely to happen.

“Shale will not take off in Mexico like it did in Texas in the near future,” Dwight Dyer, a senior analyst at the consulting company Control Risks, said by telephone from Mexico City. “Unless the security situation along the northeastern border improves significantly, smaller companies will probably take their time before jumping in.”

The Eagle Ford sedimentary rock formation underlying much of southern Texas also extends into northern Mexico’s Tamaulipas, Nuevo Leon and Coahuila states. While conventional fields that don’t require hydraulic fracturing, like the one Torrez’s crew is servicing, have been exploited for decades, just 18 shale wells have been drilled south of the border. All have been managed by the state oil company Petroleos Mexicanos, or Pemex.

North of the border, scores of wildcatters such as Pioneer Natural Resources Co. (NYSE: PXD), Chesapeake Energy Corp. (NYSE: CHK), and Chestnut Exploration and Production have been responsible for accelerating the shale boom. These companies have had to overcome myriad hurdles. These include intense opposition from environmentalists and communities over wastewater pollution, and spiraling costs. Spending on U.S. exploration and production is poised to rise 8.5% this year, according to a Barclays Plc (NYSE: BCS) report.

Although they are considerable, those obstacles pale in comparison to levels of violence in Tamaulipas that sometimes resemble a war zone. While Chestnut would be interested in looking at opportunities in Mexico at some stage, it won’t be among the first to enter, chairman Mark Plummer said from Dallas. Security is one of the turnoffs.

“There’s a big difference between Laredo and Nuevo Laredo, but once you get underneath the ground, it’s all the same,” he said, referring to the cities on either side of the border. “Hopefully over time some of that will subside.”

Gun battles raged this spring, with dozens shot dead on highways and businesses burnt down in the Gulf of Mexico port city of Tampico. The capture of a Gulf Cartel founder and the arrest last year of Zetas chief Miguel Trevino left a power vacuum that is renewing fighting between the two groups, and within the Gulf Cartel.

Congressional committees are drafting regulations to implement last year’s legislative overhaul that broke a 75-year state monopoly on oil, with the ruling party pushing to vote through the rules by mid-July.

After 15 years of congressional gridlock on energy reform, President Enrique Peña Nieto was able to push through a more extensive oil law than many investors expected, allowing companies to drill independently in Mexico. Bank of America Corp. (NYSE: BAC) estimates it will boost foreign investment, by $20 billion a year, as soon as 2015. The extra yield, or spread, that investors demand to own Pemex dollar-denominated bonds due 2023, rather than U.S. Treasury bonds, has fallen to a 1.53 percentage point from a record-high 2.39 percentage point in February.

Violence notwithstanding, shale deposits are the “low-hanging fruit,” with new exploration expected as soon as the second half of the year, according to Victor Herrera, managing director of Latin America at Standard & Poor’s. The legislative overhaul comes as output at Cantarell, the nation’s largest oil field when it was discovered, is down almost 90% since it began production in 1979.

Still, even Pemex, which has pushed ahead with some shale drilling, is fending off fuel thieves siphoning gasoline and condensates. Bunkering, as the thefts are known, led to a pipeline blast in the state of Puebla that killed 28 people and injured 52 in 2010.

The crime wave has also been hitting the national oil company’s bottom line. More than $300 million in stolen natural gas condensate from the Burgos Basin was smuggled across the U.S. border by drug cartels from 2006 to 2010, according to a lawsuit filed by Pemex in a Houston federal court in 2010. Fuel-theft losses rose to 10.3 billion pesos (US$790 million) last year, up from 3.5 billion pesos in 2009.

Many of Burgos’ wells are on unpaved roads off a highway running parallel to the Rio Grande less than a mile from the border. Highway 2 is notorious for violent attacks, narco-blockades and disappearances as rival gangs seek to secure drug routes to the U.S. Sorghum farmers in 18-wheelers share the two-lane blacktop with souped-up pickups acting as drug scouts. Few other vehicles were on the road one May afternoon.

Peña Nieto beefed up the army presence in Tamaulipas last month, where soldiers are escorting Burgos workers like Torrez to and from their wells. As it turns out, none of the Weatherford oil workers were injured in the April attack as a black Chevy Silverado fitted with steel sheets and dual wheels, known as a monster truck, pumped the dome-roofed Asya with about 20 rifle blasts. Weatherford believes the assault was unrelated to the workers’ presence, a company spokesperson said.

Since the shooting, police have captured and killed cartel leaders and tracked down those suspected of shooting at Torrez’s hotel, pumping their vehicle with more than 200 rounds. At least four men were killed as they tried to flee the makeshift tank.

“It does raise the cost of doing business when you have to face the threats of kidnapping and extortion,” said Duncan Wood, director of the Mexico Institute at the Woodrow Wilson International Center for Scholars in Washington. “For the bigger companies that’s not a big deal, but for the smaller companies, it is something they have to factor in.”