A robust employment report offered investors a pleasant surprise, but an uncertain climate kept stock markets down most of the day.

The economy added 166,000 jobs in October, the fastest pace in five months, the Labor Department said this morning. Payrolls grew more than twice what analysts had predicted, led by a sharp increase in the service sector.

The monthly jobs report is considered a bellwether of the nation’s economic health. But investors remained uneasy, with stocks fluctuating through today’s session before closing slightly higher. The Standard & Poor’s 500-stock index ended at 1,509.65, up 1.21 points, or 0.1 percent. The Dow Jones industrials gained 0.2 percent, closing at 13,595,10, up 27.23.

Big banks and brokerage houses led the declines, as Merrill Lynch’s stock plunged more than 8 percent to a two-year low after analysts questioned its relationship with several hedge funds. Investors fear the bank will be forced to write down the value of assets beyond the $7.9 billion it wrote down in the third quarter, adding to concerns about a tightening credit market.