A stock market swoon turned into a comeback Tuesday.

Stocks managed a late-afternoon rebound for the second time in two days as investors seemed to brush off a report of lower confidence among homebuilders and simmering tensions in Ukraine.

The late rally even gave a lift to tech stocks like Google and Intel, which had weighed on the market much of the day.

“As long as the market can close on a positive note, it sends a signal to investors that there are bargains in the market still to be had,” said Quincy Krosby, market strategist at Prudential Financial.

The Standard & Poor’s 500 index rose 12.37 points, or 0.7 percent, to 1,842.98.

All 10 industry sectors in the S&P 500 increased, led by utilities.

The Dow Jones industrial average added 89.32 points, or 0.6 percent, to 16,262.56. The Nasdaq composite rose 11.47 points, or 0.3 percent, to 4,034.16.

All three indexes remain down for the month and year.

The Russell 2000 index of small-company stocks, which had been down more than 1 percent earlier in the day, ended higher. The index is still off 3.8 percent for the year, more than the other major indexes. It’s also down more than 7 percent from its recent peak of 1,208 on March 4.

Small-company stocks have been racking up losses over the past five weeks, as investors look to reduce their exposure to risk. That’s a turnaround from last year, when the Russell soared 37 percent versus 30 percent for the S&P 500 index.

The stock market has been losing ground in recent weeks as investors worry about whether some tech stocks became overpriced.

Traders also remain focused on what the latest wave of quarterly earnings will say about the health of the U.S. economy and companies.

After regular trade ended Tuesday, Yahoo soared 8 percent, and Intel rose 1 percent. The two tech giants reported earnings that beat analysts’ expectations.

Several major companies, including Google, American Express, Bank of America and IBM, are due to report results today.

“We’re looking for healthy earnings growth, and so far, we’re getting it,” said Anastasia Amoroso, global market strategist at JPMorgan Chase.

Not all stocks managed to end in the green.

Most homebuilder shares slumped, with M/I Homes among the biggest decliners. The builder fell 38 cents, or 1.7 percent, to $22.11.

PetSmart posted the steepest drop among companies in the S&P 500 index after an analyst downgraded the stock, saying new competition in pet care will create trouble for the retailer. The stock fell $2.76, or 4 percent, to $66.61.

TripAdvisor led all the risers in the S&P 500 index, gaining $3.53, or 4.4 percent, to $83.30.

Coca-Cola rose $1.45, or 3.7 percent, to $40.18 after it reported that strong sales of noncarbonated drinks helped offset a first-quarter decline in soda.

Johnson & Johnson rose $2.06, or 2.1 percent, to $99.20 after the world’s biggest maker of health care products topped Wall Street expectations and raised its earnings outlook.

In Europe, Ukraine sent tanks and troops to reclaim government buildings being occupied by pro-Russian gunmen in the eastern part of the country. European governments have accused Russia of instigating the activists, raising the prospect of escalating violence and more sanctions against Moscow.