Exxon Mobil Corp (XOM.N) said it can pull out of its $30 billion acquisition of XTO Energy (XTO.N) if U.S. lawmakers pass legislation on a controversial drilling technique used to tap oil and gas fields.

Exxon would be able to walk away from the deal if U.S. lawmakers make hydraulic fracturing illegal or commercially impracticable, according to the merger agreement filed by Exxon with the U.S. Securities and Exchange Commission.

Hydraulic fracturing, or fracking, injects a mixture of water, sand and chemicals into rock formations at high pressure to force out oil and natural gas. The practice is used to stimulate production in old wells, but is now also used to tap oil and gas trapped in shale beds across North America.

On Monday, Exxon said it plans to buy XTO Energy Inc in an all-stock deal. The combined companies will have 8 million acres of shale gas and other types of unconventional resources, the largest in the industry.

The oil and gas industry says hydraulic fracturing is well regulated and safe, a position that Exxon says it supports.

Critics say the drilling chemicals have polluted aquifers in Pennsylvania and Colorado and can cause cancer and other serious illnesses.

(Reporting by Ajay Kamalakaran in Bangalore; additional reporting by A.Ananthalakshmi and Shivani Singh; Editing by Lincoln Feast)