Intel (INTC) logged a 27% decrease in fourth-quarter profits on Thursday as sales shrunk in the tough economy, but the chip giant’s results managed to surpass Wall Street’s expectations.

Shares of the world’s largest semiconductor company swung between gains and losses in extended trading following the earnings beat and new guidance for the first quarter and full year. 

Intel said it earned $2.5 billion, or 48 cents a share, last quarter, compared with a profit of $3.4 billion, or 64 cents a share, a year earlier.

Excluding one-time items, the company earned 51 cents a share, trumping consensus calls from analysts for 45 cents.

Revenue fell 3% to $13.5 billion, slightly trailing the Street’s view for $13.53 billion. Gross margins tumbled to 58% from 65.5% the year before.

“The fourth quarter played out largely as expected as we continued to execute through a challenging environment,” CEO Paul Otellini said in a statement.

Looking ahead, Intel projected first-quarter revenue of $12.2 billion to $13.2 billion, compared with the Street’s view of $12.9 billion. Gross margins are seen at 58%, plus or minus a couple of percentage points.

For the full year, Intel sees a low single-digit percentage increase in revenue and gross margins at 60%, plus or minus a few percentage points. Full-year capital spending is expected to range between $12.5 billion and $13.5 billion.

“As we enter 2013, our strong product pipeline has us well positioned to bring a new wave of Intel innovations across the spectrum of computing,” Otellini said.

Intel's fourth-quarter results were hurt by a 6% year-over-year drop in PC client revenue to $8.5 billion. The chip maker’s other architecture group posted revenue of $1 billion, representing a 7% decline from the year before and a 14% tumble from the third quarter.

On the upside, Intel’s data-center group generated 6% year-over-year revenue growth to $8.5 billion. That marked a 1.5% sequential dip.

Santa Clara, Calif.-based Intel initially rallied about 2% in after-hours trading but then headed south. In recent trading, Intel was off 1.54% to $22.33.

Intel gained 2.58% during regular trading on Thursday, trimming its 12-month slump to 9.79%.

Follow Matt Egan on Twitter @MattMEgan5