A DOZEN YEARS ago, Mexico’s voters threw out the Institutional Revolutionary Party, known as the PRI (the initials of its name in Spanish), which had ruled the country for seven decades with a broad and corrupt authoritarianism. On Sunday, polls suggest that voters will return the party to power by electing Enrique Peña Nieto, the PRI candidate, as president. But Mexico has changed dramatically since the PRI last ruled, and it isn’t going to change back.

If Mr. Peña Nieto wins, he will have to govern with more openness and accountability than any PRI predecessor. Mexico has a more organized civil society and stronger news media than ever before. The question about the telegenic Mr. Peña Nieto is not whether he would return to the past but whether he can succeed at breaking the grip of entrenched interests and drug cartels.

The war against the cartels launched by outgoing President Felipe Calderón after he took office in 2006 remains an unfinished and necessary challenge. Mr. Calderón threw the military into a battle that cost an estimated 50,000 lives — including those of many journalists — but has not uprooted the cartels. In a recent nationwide survey, the Pew Global Attitudes Project found that eight in 10 Mexicans approve of deploying the military, but fewer than half feel that progress is being made, almost a third think that the government is losing ground.

The next president will need a fresh approach. The military is no substitute for the rule of law, and human rights abuses have been rampant. The PRI long protected or colluded with drug-cartel and organized-crime figures; a few of its current governors are under investigation. Mr. Peña Nieto has proposed sending the military back to the barracks and fielding a paramilitary police force under civilian control while giving more emphasis to the social needs of youth. He also hired Óscar Naranjo, the retiring Colombian police chief who helped target drug kingpins there. Mr. Peña Nieto has promised “immediate results” to bring down violence.

Mexico’s growing middle class is a powerful catalyst for change. Leading Mexican political analysts Luis de la Calle and Luis Rubio argue in a recent report that the country’s middle class now composes a majority, and this “changes the way Mexicans think of themselves.” High expectations for modernization, transparency and stability will be frustrated if the next president cannot reform Mexico’s deep-rooted oligopolic economic structure and break the gridlock that has stymied reform in such areas as labor, taxes and energy.

The United States and Mexico are more deeply intertwined than ever — not only in the long and intractable conflicts over drugs, guns and immigration, but also as economic partners, drawn more tightly together by the North American Free Trade Agreement. Both countries have an opportunity now to get beyond some of the nettlesome issues and distrust that thwarted cooperation in the past. No matter who wins Sunday, U.S. policy should be guided by an understanding of the democracy Mexico has become, not by outdated stereotypes of the country it was a dozen years ago.