U.S. stocks fell Friday, halting a four-day rally, as investors sold to lock in profits after the Dow industrials touched a record high and Wall Street rounded out its best third quarter in nine years.

The Dow Jones industrial average briefly rose to 11,741.99, just shy of the all-time high of 11,750.28 set on Jan. 14, 2000.

"Stocks were up every day this week and they were bound for a drop," said Peter Boockvar, equity strategist at Miller Tabak & Co. in New York. "No doubt, some investors thought stocks got overbought as the quarter wrapped up."

Click here to visit FOXBusiness.com's Investing Center.

The Dow Jones industrial average fell 39.38 points, or 0.34 percent, to end at 11,679.07. The Standard & Poor's 500 Index slipped 3.30 points, or 0.25 percent, to finish at 1,335.85. The Nasdaq Composite Index declined 11.59 points, or 0.51 percent, to close at 2,258.43.

Top gainers this week, such as Caterpillar Inc. (CAT) and Altria Group (MO), were among Friday's biggest decliners. That offset a jump in some technology companies, such as Research In Motion Ltd. (RIMM) and Hewlett-Packard Co. (HPQ)

Merck & Co. (MRK) also fell after the drugmaker said Friday it would delay seeking approval for a cholesterol drug.

For the July-September quarter, the Dow rose 4.74 percent and the S&P 500 advanced 5.17 percent. The Nasdaq rose 3.97 percent. Both the Dow and the S&P 500 had their best September since 1998.

"It's been a great week, a great month and a great quarter," said Jim Awad, chairman of Awad Asset Management in New York. "It's natural to see a bit of a pause, if not some selling, after" this "type of performance."

For the week, the Dow gained 1.49 percent, while the S&P 500 advanced 1.60 percent and the Nasdaq climbed 1.78 percent.

Caterpillar, the biggest drag on the Dow, slid 1.2 percent, or 79 cents, to $65.80 and Altria declined 0.6 percent, or 42 cents, to $76.55 on the New York Stock Exchange.

Merck's stock fell 0.4 percent, or 16 cents, to $41.90 on the NYSE.

Shares of H-P rose 2 percent, or 72 cents, to $36.69 on the NYSE a day after Chief Executive Mark Hurd testified at a congressional hearing about boardroom leaks. Argus Research analyst Wendy Abramowitz said "positive interpretations" of the hearings were underpinning the stock. It was H-P's biggest advance in more than two months. The stock was the top gainer in both the Dow and the S&P 500, which helped cushion their declines on Friday.

Shares of Research in Motion jumped 19.3 percent, or $16.59, to $102.65 on Nasdaq a day after the maker of the BlackBerry handheld wireless e-mail devices reported a higher-than-expected second-quarter profit. On Friday, brokerage Deutsche Bank raised its rating on the stock.

The stock was the Nasdaq's biggest gainer.

Friday's economic data included a report that showed business activity in the U.S. Midwest unexpectedly rose in September, according to the National Association of Purchasing Management-Chicago's index.

The University of Michigan's final reading on consumer sentiment in September exceeded both the mid-month reading and August's final reading.

Trading was moderate, with about 1.47 billion shares changing hands on the NYSE, below last year's daily average of 1.6 billion. On Nasdaq, trading was heavier, with 1.88 billion shares traded, above last year's daily average of 1.80 billion.

Decliners outnumbered advancers across the board, with about three stocks falling for every two that rose on both the NYSE and the Nasdaq.

Click here to visit FOXBusiness.com's Investing Center.