A rally that pushed a key index to a record high petered out on Friday.

Despite the losses, the market still ended with its best week in nearly two months after getting a boost from the Federal Reserve on Wednesday. Policymakers signaled that they were in no hurry to raise interest rates from historically low levels.

“Many sectors and stocks have had a good few days, so some of it is (down to) people taking off some of their profits,” said JJ Kinahan, TD Ameritrade's chief strategist about Friday's trading.

The Standard & Poor's 500 index lost 11.48 points, or 0.5 percent, to 2,109.76. For the week the index was up 0.8 percent, its best gain since the week ending April 24.

The Dow Jones industrial average fell 99.89 points, or 0.6 percent, to 18,015.95.

The Nasdaq composite slid 15.95 points, or 0.3 percent, closing at 5,117. That's just below its record high of 5,132.95 set on Thursday.

Oct. 1 -- U.S. markets suffered their worst quarter since 2011 in the third quarter with all three indexes falling by at least seven percent. Bloomberg's Julie Hyman recaps the market carnage on "Bloomberg Surveillance."

Oct. 1 -- U.S. markets suffered their worst quarter since 2011 in the third quarter with all three indexes falling by at least seven percent. Bloomberg's Julie Hyman recaps the market carnage on "Bloomberg Surveillance."

CAPTION

Sept. 30 -- The Senate passed a U.S. government spending plan hours before a shutdown deadline, sending the bill to the House where Speaker John Boehner promised a vote over objections from fellow Republicans who wanted to use it to defund Planned Parenth

Sept. 30 -- The Senate passed a U.S. government spending plan hours before a shutdown deadline, sending the bill to the House where Speaker John Boehner promised a vote over objections from fellow Republicans who wanted to use it to defund Planned Parenth

CAPTION

Target announced it will match its online prices to the prices of nearly two dozen online competitors beginning Thursday. Sept. 30, 2015 (CBS Minnesota)

Target announced it will match its online prices to the prices of nearly two dozen online competitors beginning Thursday. Sept. 30, 2015 (CBS Minnesota)

An impasse in bailout negotiations between Greece and its creditors and worries about a stock bubble in China weighed on the market. Utilities and financials stocks were among the biggest decliners. The price of oil fell, ending the week nearly flat.

Investors spent much of the week focused on the Federal Reserve's next move on interest rates.

The market got some reassurance from the central bank on Wednesday, when the Fed suggested it wanted to see more improvement in the economy and signs of inflation before raising rates. The low rates have helped drive the bull market in stocks.

Clarity on Greece's ongoing debt drama has been more elusive.

Greece and its lenders remain deadlocked in their attempts to hammer out a pact for the debt-stricken nation. Greece needs more loans from its creditors before June 30, when its current bailout program expires and a 1.6 billion euro ($1.8 billion) debt payment is due.

On Friday, the European Central Bank agreed to provide temporary support for Greece's banks ahead of an emergency summit meeting next week. That meeting could determine whether Greece still has a future in the euro. Greece's main stock index slumped 11 percent for the week.

Traders also had their eye on China, where the main stock index plunged Friday, raising concerns that a bubble in the market may have burst. The Shanghai Composite Index tumbled 6.4 percent and is 13 percent lower for the week. The index has more than doubled in the past year.

A series of disappointing sales forecasts also hurt stocks.

Hershey fell 3.5 percent after the chocolate and candy maker cut its revenue outlook for the year because of weak demand in China. The company also said it plans to cut about 300 jobs by the end of the year. The stock lost $3.22 to $89.04.

CarMax fell 3.7 percent after the used car dealership chain reported fiscal first-quarter sales that fell short of forecasts. The stock shed $2.69 to $69.27.

Jana said ConAgra's results have been disappointing since it bought Ralcorp, the owner of Post cereals, in January 2013, and asked the packaged food company to extend the deadline for nominating board candidates.

The dollar fell to 122.61 yen from 123.04 yen on Thursday. The euro fell against the dollar to $1.1357 from $1.1371.

In energy trading, benchmark U.S. crude fell 84 cents to close at $59.61 a barrel in New York. Oil finished last week at $59.96. Brent crude, a benchmark for international oils used by many U.S. refineries, fell $1.24 to close at $63.02 in London.

In other energy futures trading, wholesale gasoline fell 5.1 cents to close at $2.059 a gallon. Heating oil fell 4.8 cents to close at $1.867 a gallon. Natural gas rose 3.9 cents to close at $2.816 per 1,000 cubic feet.

In metals trading, the price of gold was little changed at $1,201.90 an ounce. Silver dropped 4.4 cents to $16.11 an ounce. Copper declined 3.7 cents to $2.57 a pound.

U.S. government bond prices rose. The yield on the 10-year Treasury note, which falls when prices rise, dropped to 2.26 percent from 2.32 percent late Thursday.