Stocks closed little changed on Monday as strength in semiconductor stocks tied to Intel Corp.'s higher sales outlook offset lingering concerns about the mortgage market.

An afternoon rally fizzled when oil shot to within a whisker of a record, sparking fresh worries that high gasoline costs will squeeze consumer spending.

Semiconductor stocks stood out on the session after Intel said strong global demand would drive its third-quarter sales above its previous forecast, and technology hardware shares rose with news that Apple Inc. had sold its millionth iPhone.

The effect of Intel is broad-based. It sounds like they are seeing some good top line revenue growth along with some margin expansion, and we've been seeing that for a while -- the forecast that revenue in the PC world seems to be picking up, said Owen Fitzpatrick, head of U.S. Equity Group, Deutsche Bank Private Wealth Management in New York.

But Countrywide Financial Corp., the largest U.S. mortgage lender, declined 5.5 percent to $17.21. UBS slashed its share price target on the stock and cut its 2007 and 2008 earnings estimates. Late Friday, Countrywide announced it was cutting up to the 12,000 jobs.

The Dow Jones industrial average rose 14.47 points, or 0.11 percent, to end at 13,127.85. The Standard & Poor's 500 Index was down 1.85 points, or 0.13 percent, at 1,451.70. The Nasdaq Composite Index was down 6.59 points, or 0.26 percent, at 2,559.11.

The Countrywide news is underscoring the difficulties still ahead for anybody tied to the mortgage business, said Michael James, senior trader at regional investment bank Wedbush Morgan in Los Angeles.

Home builders were down. Shares of Lennar Corp fell 2.4 percent to $25.88 and shares of Pulte Homes Inc were down 3 percent at $15.04.

However, Bear Stearns Cos shares rose 2 percent to $107.50, leading brokers higher, after a securities filing showed Joseph Lewis, a Bahamas-based billionaire, had acquired 7 percent of Bear's beaten-down stock. A bullish call on the financial sector by Citigroup added to the momentum for bank stocks.

Apple gave the biggest lift to the Nasdaq after it said its iPhone sales hit 1 million a few weeks ahead of target. Apple's shares rose 3.8 percent to $136.71.

Shares of Intel ended down 0.5 percent at $25.35 after gaining for most of the session, while the Philadelphia Stock Exchange index of semiconductors advanced 0.6 percent. The chip maker raised its third-quarter revenue forecast and said gross margins would be at the high end of its target range.

U.S. crude oil futures extended gains, climbing near the record high above $78 in late electronic trading on a rash of short-covering ahead of Tuesday's policy-setting OPEC meeting in Vienna.

Meanwhile, San Francisco Federal Reserve Bank President Janet Yellen said the turmoil in financial markets has added appreciably to downside risk for the U.S. economy, but that goals of price stability and full employment must be the focus of policy-makers and not shielding investors from losses.

Yellen was among several Federal Reserve officials speaking on Monday. Markets were searching for any hints how the Fed's policy-setting arm will act when it meets to decide on interest rates on September 18.

U.S. rate futures suggest the Fed will cut its benchmark rate from 5.25 percent to ensure a healthy economy, but analysts were divided how aggressively the central bank will lower rates in the near term and during the rest of the year.

Trading was below average on the New York Stock Exchange, with about 1.34 billion shares changing hands, below last year's estimated daily average of 1.84 billion, while on Nasdaq, about 1.82 billion shares traded, below last year's daily average of 2.02 billion.

Declining stocks were outnumbering rising ones by a ratio of about 5 to 3 on the NYSE and by nearly 2 to 1 on Nasdaq.