Federal Reserve Chair Janet Yellen's soothing words on interest rates, reiterating that they would probably climb only gradually, were music to Wall Street's ears.

The S&P 500 added 0.88% and the Dow Jones Industrial Average gained 0.56%, both closing at year-to-date highs. The S&P moved back into positive territory for the year, and the Nasdaq climbed 1.7%.

The central bank's monetary policy committee should "proceed cautiously" in adjusting interest rates, Yellen said Tuesday during a speech in New York. While the labor market and consumer spending are improving, "manufacturing and net exports have continued to be hard hit by slow global growth and the significant appreciation of the dollar since 2014," she noted. Other risks include a slowing Chinese economy and oil prices still well below their 2014 peak.

At its March meeting, the Fed downgraded its policy forecast to two rate hikes this year from four. Recent comments from monetary policy committee members such as St. Louis Fed President James Bullard, however, suggest that an April rate hike isn't off the table. The odds of an April rate hike climbed to 14% from 7% following Bullard's comments, according to CME's FedWatch futures.

Yellen "does continue to be dovish," Paul Springmeyer, regional investment strategist at the Private Client Reserve at U.S. Bank, told TheStreet. "She's been very consistent in that regard... [The Fed] has been quite transparent about what they've been doing, so the markets have reacted positively to that just because there have really been very few surprises."

The tech sector was the best performer on markets Tuesday, leading the Nasdaq in its rally. Tech giants such as Alphabet (GOOGL) , Microsoft (MSFT) , Facebook (FB) and Alibaba (BABA) were higher, while the Technology Select Sector SPDR ETF (XLK) added 1.6%.

Alphabet and Facebook are holdings in Jim Cramer's Action Alerts PLUS portfolio.

Exclusive Look Inside: You see Jim Cramer on TV. Now, see where he invests his money and why Alphabet is a core holding of his multi-million dollar portfolio. Learn more now.

Consumers felt more confident in March as stock markets rebounded from a poor start to the year, while speculation of a recession became less frequent. Confidence rose to 96.2 in March, up from a revised 94 in February, the Conference Board said. Economists expected the index to rise to 94.2.

Home prices jumped 5.7% in January as tight inventories continue to push values higher, according to the S&P/Case-Shiller 20-city index. Denver, San Francisco and Seattle saw double-digit percentage increases.

Crude oil slumped again as a hangover from last week's disappointing domestic data on the oil industry continued. Oil has seen a renewed push lower on signs a domestic supply glut is worsening as inventories build by millions of barrels each week. The American Petroleum Institute will release data on crude inventories this evening. West Texas Intermediate crude fell 2.7% to $38.33 a barrel.

The standoff between the FBI and Apple (AAPL) abruptly ended on Monday after prosecutors asked a federal judge to vacate a disputed order for the company to break into a phone used by the San Bernardino terrorists. The FBI said it had used an alternative method to unlock the phone, though the agency didn't divulge its workaround. The case had triggered debate over whether Apple, a holding in Jim Cramer's Action Alerts PLUS portfolio, should acquiesce and potentially weaken all customers' security. 

Yahoo! (YHOO) reportedly has given potential buyers an April 11 deadline to submit bids for its core Internet business and Asian assets, such as stakes in Alibaba (BABA) and Yahoo! Japan. The company is looking to narrow the field to around 40 bidders.

More from Markets

Three Big Factors That Rocked the Stock Market Tuesday

Three Big Factors That Rocked the Stock Market Tuesday

Dow Tumbles Over 400 Points; S&P 500 and Nasdaq Also Finish Lower

Dow Tumbles Over 400 Points; S&P 500 and Nasdaq Also Finish Lower

Caterpillar Bulldozes Industrial Sector With Bad News on Earnings Call

Caterpillar Bulldozes Industrial Sector With Bad News on Earnings Call

Jim Cramer: If You're Afraid of the 10-Year Yield, Go to Cash

Jim Cramer: If You're Afraid of the 10-Year Yield, Go to Cash

Eli Lilly CEO Expresses Confidence in New Rheumatoid Arthritis Drug

Eli Lilly CEO Expresses Confidence in New Rheumatoid Arthritis Drug