Drugmaker Pfizer gave the Dow a lift after posting a strong earnings report. That helped push the index closer to 14,000.
The Dow Jones industrial average closed at 13,954. The index has advanced seven of the past eight days. The Standard and Poor's 500 gained 7 points to 1,507. The Nasdaq composite fell less than a point to 3,153.
Stocks are approaching record levels after a January rally that has pushed the Dow 6.5 percent higher this month and the S&P 500 up 5.7 percent, to its highest level since December 2007. Demand was bolstered after lawmakers reached a deal to avoid the "fiscal cliff" at the start of the year.
Advancing stocks outpaced declining ones on the New York Stock Exchange. Volume was above average at 3.9 billion shares.
The S&P 500 is on track to post its best monthly performance since October 2011 and its best January since 1997 as investors poured $55 billion in new cash into stock mutual funds and exchange-traded funds in January, the biggest monthly inflow on record.
Among rising defensive shares, which are companies relatively immune to economic swings, were Pfizer and AT&T .
"After the kind of rally that we had since the beginning of the year, many investors are becoming more cautious but there is fundamental reasons to be moving in the direction that we are moving in," said Joseph Tanious, global market strategist at J.P. Morgan Funds.
"The 1,500 on the S&P is the psychological barrier but there are still more tailwinds than headwinds in the market."
"Cyclical were moving very nicely, now you see balance with some of the defensive. Many managers use that as an internal hedge in equity portfolios," said Quincy Krosby, market strategist at Prudential Financial in Newark, New Jersey.
She said the market is cautious ahead of Wednesday's statement following the Federal Reserve's two-day meeting. In addition, defensive stocks would hold up better if Friday's payrolls report surprises on the downside.
The S&P hovered near 1,500, and market technicians say the benchmark is at an inflection point which will determine the overall direction in the near term.
"The public is pouring in now," said Carter Worth, chief market technician at Oppenheimer & Co in New York. "It reflects complacency and that typically leads to hubris, and hubris leads to trouble. Everyone's buying."
The energy sector also advanced, on the back of strong earnings from Valero Energy Corp and a hedge fund move to break up Hess Corp to boost investor returns.
Valero shares jumped 10.8 percent to $42.99 and Hess gained 8.1 percent to $67.56.
The equity gains have largely come on a strong start to earnings season, though results were mixed on Tuesday with Pfizer rising but Ford Motor Co down after its report.
Both companies reported profits that topped expectations, but Ford also forecast a wider loss in its European segment. Ford dropped 5.6 percent to $13.01 as one of the biggest percentage losers on the S&P 500.
Thomson Reuters data showed that of the 174 companies in the S&P 500 that have reported earnings this season, 68.4 percent have been above analyst expectations, which is a higher proportion than over the past four quarters and above the average since 1994.
Disappointing outlooks from Seagate Technology and BMC Software pressured their shares. Seagate lost 9.6 percent to $33.82 and BMC fell 8.5 percent to $40.70.
Software maker VMware Inc lost 21 percent to $77.71 also after a cautious 2013 outlook.
Amazon was the biggest drag on the Nasdaq with a 3.2 percent drop to $267.17 before its results, expected after the closing bell.
U.S. home prices rose in November to rack up their best yearly gain since the housing crisis began, a further sign that the sector is on the mend, but consumer confidence fell to its lowest level in more than a year in the wake of higher taxes for many Americans.
The Associated Press and Reuters contributed to this report.