NEW YORK — Crisis-weary investors scoffed Monday at what had appeared to be a hopeful turn in the European debt crisis: a victory for pro-Europe parties in a Greek election. U.S. stocks were little changed, and borrowing costs for Spain surged to alarming levels.

Investors appeared fed up with policymakers' inability to resolve a crisis that has bedeviled markets for more than three years. Leaders of the most developed countries are meeting in Mexico to discuss the crisis and the slowing global economy.

"Even though we avoided the worst-case scenario in Greece, the crisis has entered a new and dangerous phase, and it doesn't end with Greece," said Michelle Gibley, director of international research at the Schwab Center for Financial Research.

U.S. indexes opened lower and then drifted between modest gains and losses. Homebuilders rallied after a measure of confidence among U.S. builders rose to a five-year high.

Spanish borrowing rates spiked Monday above levels that forced other countries to take bailouts, a sign that bond investors fear Spain will default on its debts.

The Dow Jones industrial average closed down 25.35 points, or 0.2 percent, to 12,741.82. The Nasdaq composite index rose 22.53 points, or 0.8 percent, to 2,895.33. It was lifted by Apple, its biggest component, which rose $11.65, or 2 percent, to $585.78.

The Standard & Poor's 500 rose 1.94 points, or 0.1 percent, to 1,344.78. Of its 10 major industry categories, only financials and energy stocks fell. Energy companies followed oil prices lower.

On Sunday, Greek voters elected a party that wants to continue a program of international bailout loans that are conditioned on painful budget cuts. Traders had fretted for weeks that a radical leftist party would prevail and reject Europe's unpopular bailout plan.

The next step, traders feared, would be Greece's dropping the shared currency. Anxiety over a Greek exit was so pronounced that many expected bank runs Monday if anti-bailout parties had won the election. Banks would be hit hard if the European financial crisis were to spin out of control.