Updated

Stocks ended slightly higher on Friday but stayed near lows for the year as oil prices surged past $46 a barrel, offsetting a positive outlook from computer maker Dell Inc. (DELL)

The Dow Jones industrial average closed up 10.76 points, or 0.11 percent, at 9,825.35. The Standard & Poor's 500 Index was up 1.57 points, or 0.15 percent, at 1,064.80. The technology-laced Nasdaq Composite Index was up 4.73 points, or 0.27 percent, at 1,757.22.

For the week, the Dow rose 0.12 percent and the S&P 500 advanced 0.08 percent, while the Nasdaq fell 1.11 percent.

Trading was moderate, with 1.2 billion shares changing hands on the New York Stock Exchange, below the 1.4 billion daily average for last year. About 1.3 billion shares were traded on Nasdaq, below the 1.69 billion daily average last year.

Advancers outnumbered decliners on the NYSE by around 3 to 2. On Nasdaq, decliners and advancers were around equal.

Dell, the world's largest PC producer, rose more than 4 percent after it gave a better-than-expected third-quarter outlook.

But countering this was another peak in the price of oil. U.S. crude has hit new highs for 10 out of the last 11 sessions. A fire at an Indiana refinery and worries over possible supply disruptions in Iraq  and Venezuela were behind Friday's leap.

"Unless you see a pullback in oil, it's going to be hard to sustain any rally," said Peter Boockvar, equity strategist at Miller Tabak & Co.

"This market has turned into a bear and rallies will be modest while the path of least resistance is lower."

Early momentum fizzled out as the day wore on, although all the indexes managed to close in positive territory. On Thursday, blue chips closed at their lowest level this year and the Nasdaq slumped to its worst since August following poor news from the technology sector and a hike in oil prices.

"It is a combination of the summer, lower than typical liquidity and all sorts of headline issues -- for energy and for the economy on down," said Jack Caffrey, equity strategist at JP Morgan Private Bank.

NYMEX September crude rocketed to $46.65 per barrel before nudging back to settle at $46.50, its first ever close above the $46 mark.

High oil prices put a dampener on stock prices as investors worry about the impact on consumers' wallets and companies' profit margins.

But energy stocks benefited. Exxon Mobil Corp. (XOM) rose 36 cents to $44.92, ChevronTexaco Corp. (CVX) gained $1.23 to $95.60 and ConocoPhillips (COP) rose 90 cents to $73.47.

On the economic front, data showed the U.S. trade deficit widened much more than expected in June, hitting a record $55.8 billion dollars, the government said. Consumer confidence deteriorated in early August, reversing July's increases, as expectations for the economy worsened, according to a survey from the University of Michigan.

Dell was the star of the tech sector, rising $1.39 to $34.51 after its upbeat report, which was in contrast to several gloomy forecasts by other bellwether tech companies this week.

Electronics and testing equipment maker Agilent Technologies Inc. (A) also rose, a day after it posted a quarterly profit versus a year earlier loss. Its stocks gained 84 cents, or 4.27 percent, to $20.52.

But some tech stocks faced selling, such as Analog Devices Inc. (ADI), which makes chips for cell phones and said revenue growth was slower than it expected. Analog Devices fell 26 cents to $33.57.

Cisco nudged higher after Morgan Stanley upgraded the stock to "overweight" from "equal weight." Cisco was up 7 cents to $17.86.

But Hewlett-Packard Co. (HPQ) fell a day after it posted quarterly earnings well below forecasts. Shares were down 45 cents at $16.50 on Friday.

The Russell 2000 index of smaller companies was up 0.29, or 0.1 percent, at 517.39.

Overseas, Japan's Nikkei stock average tumbled 2.5 percent. In afternoon trading, Britain's FTSE 100 closed down 0.6 percent, France's CAC-40 dropped 0.3 percent for the session, and Germany's DAX index fell 0.3 percent in late trading.