Major U.S. stock indexes finished mostly higher Friday, eking out gains with a dramatic rally into the closing bell. The bounce allowed the S&P 500 index to narrowly avoid a bear-market finish, while ending the session virtually flat around 3,901. The Dow Jones Industrial Average rose less than 0.1% and the Nasdaq Composite Index shed 0.3%. Stocks have been under sharp pressure this week as a string of big-box retailers from Walmart Inc. to Ross Stores, Inc. reported disappointing quarterly results, raising fears about a potential pullback in spending from consumers as the Federal Reserve looks to cool high inflation by raising rates and reducing its near $9 trillion balance sheet, but without sparking a recession. Market jitters also led investors to look for safety in government debt, with the 10-year Treasury yield falling to 2.785% Friday, retreating for a second week in a row. Bond yields and prices move in the opposite direction. Earlier in the session, the S&P 500 traded into bear-market territory, but required a close below 3,837.25 to make the status official, marking a fall of 20% or more from its Jan. 3 record close. For the week, the Dow recorded a 2.9% decline, its eighth straight weekly decline, and its longest stretch since April 1932, according to Dow Jones Market Data. The S&P 500 shed 3% for the week, while the Nasdaq lost 3.8%.

Market Pulse Stories are Rapid-fire, short news bursts on stocks and markets as they move. Visit MarketWatch.com for more information on this news.