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, 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 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.

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 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, which 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.

The courage of the reform program can be seen in Peña Nieto's lackluster opinion polls: The payoff will mostly be in the longer term. It's still possible that the oil reform could be stopped.

For now, however, 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.