The stock market enjoyed some Black Friday cheer, rising sharply as shoppers braved the annual post-Thanksgiving rush. Major stock indexes closed one of their best weeks of the year.

Traders were encouraged by positive news from Germany and China, two engines of global growth. Technology stocks soared after a few weeks of selling. Early reports from retailers suggested strong consumer spending.

“Foot traffic appears heavier than we’ve seen in recent years; there are a lot of positive statements out of the companies themselves; and momentum appears to be strong,” said J.J. Kinahan, chief derivatives strategist at the brokerage TD Ameritrade.

Many stores opened earlier than ever this year, Kinahan said, allowing for earlier informal reports about their performance.

Technology stocks soared, lifting the Nasdaq composite index by more than 1 percent. Dell, chipmaker AMD and Hewlett-Packard were the top three gainers in the Standard & Poor’s 500. Technology rose the most among the index’s 10 industry groups.

The stocks were bouncing back after confidence in tech stocks declined broadly, Kinahan said. AMD dropped sharply in recent weeks as investors fretted about its solvency. HP plunged 12 percent on Tuesday after executives said that a company HP bought for $10 billion last year lied about its finances.

The Nasdaq ended up 40.30 points, or 1.4 percent, at 2,966.85. The Dow Jones industrial average gained 172.79, or 1.4 percent, to 13,009.69 — the first time since election day that the Dow closed above 13,000.

The S&P 500 added 18.12, or 1.3 percent, to 1409.15. The rally gave the S&P 500 its biggest weekly point gain since last December — 49 points, or 3.6 percent. The Dow gained 3.4 percent and the Nasdaq almost 4 percent for the week.

The market closed early at 1 p.m. as it routinely does after Thanksgiving.

Stocks started strong after news that German business confidence rose unexpectedly in November after six consecutive declines. China’s manufacturing expanded for the first time in 13 months in November, the latest sign that the world’s second-biggest economy is recovering from its deepest slump since the 2008 global crisis. HSBC Corp. said its monthly Purchasing Managers’ Index improved to 50.4 for November. Any number above 50 indicates expansion.

Around the U.S., shoppers flocked to malls and logged on to computers to take part in the annual cheer-fueled retail rush known as Black Friday. Retail is a key driver of the nation’s economy. Consumer spending accounts for about 70 percent of U.S. economic activity. Wal-Mart rose $1.31, or 1.9 percent, to $70.20. Macy’s gained 72 cents, or 1.8 percent, to $41.73.