Yellen gave her speech, titled "The Outlook, Uncertainty, and Monetary Policy," at the Economic Club of New York.
"One of the most important things she said is there's a recognition in the Fed that there were very turbulent times in January," said Alan Rechtschaffen, financial advisor and senior vice president at UBS Wealth Management Americas.
"I think she's uncertain," he said. "I think the fact they say they're uncertain means they're uncertain."
Recent policymaker comments have leaned more hawkish than what came out of the March 15-16 meeting, which was more dovish than many expected.
"No doubt Yellen is the clear leader of the Fed and her opinion weighs heavily," said Mike Arone, chief investment strategist for the U.S. intermediary business at State Street Global Advisors.
U.S. stocks opened lower as declines in oil prices weighed. U.S. crude oil futures settled down $1.11 at $38.28 a barrel.
The major averages pared losses and the Nasdaq composite turned higher after consumer confidence showed a rise in March to 96.2 from 94.0 in February.
"That's a good sign," said Peter Cardillo, chief market economist at First Standard Financial.
Apple, Microsoft, Amazon.com and Facebook closed more than 2 percent higher to support gains in the Nasdaq. The iShares Nasdaq Biotechnology ETF (IBB) turned higher to close up 1.8 percent.
With Tuesday's gains, Apple came within 20 percent of its 52-week intraday high, out of bear market territory.
Late Monday, the Justice Department said it no longer needs Apple's help after accessing data on the iPhone used by a shooter in last year's San Bernardino, California, attacks.
"We believe the resolution is a net positive for Apple. ... It alleviates a potential risk for Apple," said Angelo Zino of S&P Capital IQ, which maintained its "strong buy" recommendation on Apple stock in an early Tuesday note.
In other central bank news, Dallas Federal Reserve President Robert Kaplan said in a Reuters report he expects the U.S. economy to prove resilient this year but that the nation's central bank should proceed gradually and cautiously in raising rates.
In comments to reporters Kaplan declined to rule out a rate increase at the Fed's April meeting, Reuters said.
He was scheduled to speak again at 4 p.m. ET.
Earlier, in a speech at the National University of Singapore, San Francisco Fed President John Williams said the U.S. economy remains on track for a gradual path of interest rate hikes and fears over the impact of a slowing global economy and bouts of financial volatility are overdone.
Williams is a non-voting member of the Federal Open Market Committee this year, while Kaplan is an alternate member.
Separately, the S&P/Case-Shiller 20-City Composite Index for January showed a 5.7 percent rise from the previous year. The March jobs report is due Friday.
Lennar beat estimates by 11 cents with earnings of 63 cents a share, on revenue that also topped expectations. The home builder reported a nearly 10 percent increase in new orders and a 12 percent rise in deliveries.
The stock closed up 3.17 percent, helping the SPDR S&P Homebuilders ETF (XHB) gain nearly 1.7 percent for its best day since March 11.
Overseas, major European indexes closed mostly higher. Asian equities closed mostly lower, with the Shanghai composite off more than 1 percent and the Nikkei 225 about 0.2 percent lower. The Hang Seng closed up 0.1 percent.
Read MoreEarly movers: LEN, MKC, YHOO, AAPL, CMG, VA, KERX, AMBA, EBAY & more
The Dow Jones industrial average gained 97.72 points, or 0.56 percent, to 17,633.11, with Apple leading advancers and 3M the greatest decliner.
The S&P 500 closed up 17.96 points, or 0.88 percent, at 2,055.01, with information technology leading all 10 sectors higher.
The Nasdaq composite closed up 79.84 points, or 1.67 percent, at 4,846.62.
The CBOE Volatility Index (VIX), widely considered the best gauge of fear in the market, fell below 14.
About four stocks advanced for every decliner on the New York Stock Exchange, with an exchange volume of 968 million and a composite volume of 3.8 billion.
Trade volume on Monday was the lowest of the year so far, following the holiday-shortened week that saw three of the lowest trade volume days of the year so far.
—Reuters contributed to this report.
On tap this week:
8:15 a.m.: ADP employment
1 p.m.: $28 billion 7-year note auction
8:30 a.m.: Jobless claims
9:30 a.m.: Chicago Fed President Charles Evans
9:45 a.m.: Chicago PMI
5 p.m.: New York Fed President William Dudley
March vehicle sales
8:30 a.m.: Employment report
9:45 a.m.: Manufacturing PMI
10 a.m.: ISM manufacturing
10 a.m.: Construction spending
10 a.m.: Consumer sentiment
1 p.m.: Cleveland Fed President Loretta Mester
*Planner subject to change.
More From CNBC.com: