WHILE CONGRESS was congratulating itself on reaching a minimalist bipartisan deal on the budget, Mexico demonstrated how a more functional democracy can tackle a nation’s biggest and most sensitive problems. The ruling Institutional Revolutionary Party (PRI) and the opposition National Action Party (PAN) joined last week to pass a constitutional amendment dismantling what, for Mexico, is the mother of all political third rails: the state’s monopoly on oil production. While the fight’s not entirely over and its benefits won’t be seen for several years, the action is a triumph for President Enrique Peña Nieto, and it opens the door for a Mexican economic takeoff.

Using terms like functional or democracy to describe Mexico would have been far-fetched not so long ago. Not until the 1990s did the country have genuinely free and competitive elections, and when the PRI was finally ousted from power by the PAN, the result was gridlock that left long-festering problems unaddressed. Chief among them was the state oil monopoly Pemex, which lacked the capital or expertise to develop new fields offshore but which was prevented from partnering with multinationals by a constitutional commitment to nationalization considered sacrosanct by two generations of Mexicans. With reform blocked, Mexico’s oil production declined by a quarter in the last decade, and exports to the United States declined by a third.

Mr. Peña Nieto, who took office a year ago, managed to break the impasse by fashioning Mexico’s version of a grand bargain with the PAN and left-wing legislators. The parties agreed on and passed a series of groundbreaking reforms in education, taxation, banking and telecommunications. Among the key results was to break the stifling power of Mexico’s corrupt teachers unions and expose private telephone and television conglomerates to competition.

While some of those reforms were watered down as they moved through Mexico’s congress, the oil reform was made more ambitious, thanks to pressure from the PAN and the counterproductive decision of leftists to adopt a strategy of intransigence. Foreign firms will be able to partner with Pemex, to explore and drill for oil, and to book expected revenues from production for accounting purposes, a key to obtaining financing. The notoriously inefficient Mexican firm will have a revamped governance that eliminates union members from its board. Private companies also will compete to supply electricity to the national grid, which should lower energy costs for consumers and industry.

The courage of the reform program can be seen in Mr. Peña Nieto’s lackluster opinion polls: The payoff will mostly be in the longer term, so most Mexicans have yet to see tangible improvements. Economic growth has been lackluster in the past year and the drug war — the focus of Mexico’s most recent previous president — drags on. It’s still possible that the oil reform could be stopped — it must be ratified by Mexican states and implemented in legislation — and it’s possible opponents will succeed in winning approval for a referendum.

For now, however, Mr. Peña Nieto and his coalition can savor a historic breakthrough that positions Mexico to restore its place as a major oil producer, attract billions in investment and modernize its economy. As Venezuela’s economy implodes and Brazil’s growth stalls, Mexico is becoming the Latin oil producer to watch — and a model of how democracy can serve a developing country.