Mexico's Congress approved changes this week to open energy development to foreign firms for the first time since 1938, opening a potential gusher of new investment from United States firms.

Mexican President Enrique Peña Nieto has signaled he'll sign the laws, which could attract large companies like ExxonMobil to deepwater projects and smaller, independent ones that have led an oil and gas boom north of the border to Mexico's shale plays.

The changes are a win-win for foreign private firms that have wanted to tap into Mexico's potentially lucrative deposits and for the Mexican government, which derives about one-third of its budget from oil and gas revenues but has seen output drop from 3.4 million barrels of oil per day in 2004 to 2.5 million now.

Mexican government entities will still reserve the rights to sizable portions of offshore and onshore land for drilling and exploration, but the provisions finalized Wednesday outline ways for foreign companies to enter the market.

On the production side, Mexican government entities would have the option to enter into joint ventures with foreign firms, and those firms would tally the reserves at theirs, a key provision for the industry. An independent commission would decide that partner following a public bidding, but that's not likely to commence until 2015, said Fernando Cano-Lasa, a Houston-based attorney with Squire Patton Boggs who works on energy and infrastructure issues in Latin America.

That's a likely scenario for deepwater projects, where the state-owned Pemex has little capital, expertise and infrastructure to go it alone, and onshore hydraulic fracturing, or fracking, again chalked up to scarce technical knowhow.

"The focus on this point was really on creating an environment to allow Pemex to be competitive," said Ken Medlock, an energy fellow at Rice University's James A. Baker III Institute for Public Policy.

On the downstream and midstream side — think refineries and building pipelines — the Mexican government will open a permitting process to all bidders, though the details on what would be required of applicants are unclear.

There are some other caveats on the production side, and some of the specifics are still a bit murky.

Foreign firms will have to form a wholly owned Mexican subsidiary, which will help the Mexican government collect taxes from development. The tax burden is still unknown.

Medlock noted that local content requirements could be a deterrent for U.S.-based firms that provide services to the industry. If they're too high, companies based in western Texas or Louisiana might not enter the market, he said.

Mexico would also require a 20 percent stake in fields that cross national borders. That would include the Gulf of Mexico and the Boquillas shale formation in northern Mexico, which in the U.S. is known as southern Texas' Eagle Ford shale formation.

"Understandably, the Mexican government wants to have a certain interest in those fields," Cano-Lasa told the Washington Examiner.

Despite all that, U.S. companies appear to be in a big position to benefit.

Pemex will focus its resources on shallow water plays, while oil "majors" will likely fill the deepwater void. And Pemex has had little luck tapping shale oil and gas, making U.S. pioneers that spearheaded the fracking revolution well positioned to dominate the Mexican market.

"When you go deepwater, they've got no history of success there," Luis Gomar, a partner with Dallas law firm Strasburger and Price LLP, told the Examiner in a phone call. Of potential onshore shale development, he added, "I believe there is a huge opportunity for smaller operators who have an entrepreneurial spirit, who are not necessarily risk averse, and can really take advantage of tapping into untapped territory."

That shale oil and gas exists in Mexico isn't questioned. The Eagle Ford — the mirror Image of Mexico's Boquillas shale — produces roughly 1.4 million barrels of oil per day, according to the U.S. Energy Information Administration, the Energy Department's statistics arm.

The risk, instead, is security. For as much as what's beneath the ground holds riches, drug cartels reign above it. Gomar said that's simply "another line item" that drilling firms will have to convince investors to pay for.

Medlock is less convinced, noting that some drillers in the Eagle Ford have a habit of locking down well sites at night because of security risks. He said a few drillers might dare to try, but not enough to make a dent, noting that it takes drilling thousands of wells to prime the shale pump.

"If there's a lot of activity that starts to commence, that raises a lot of concerns," Medlock said. "There's a history of cartels using kidnapping to leverage themselves."