Stocks finished the last day of the quarter with gains, but it wasn't clear that would happen until the final moments of trading. However, one statistic was clear all day -- the Standard & Poor's 500 index was destined for its worst first half year since 2010.
The S&P closed Tuesday up 0.2 percent for the year, although it broke a string of gains stretching nine quarters.
At the close on Wall Street, the S&P 500 was up 5.5 points, about 0.3 percent, at 2,063.1. The Dow Jones industrial average closed up 23.2 points, about 0.1 percent, at 17,619.5 after falling 350 points Monday, the most since October. The Nasdaq composite climbed 28.4 points, about 0.6 percent, to nearly 4,987.
As the markets closed, the price of an Aug. 15 contract for U.S. benchmark crude oil was up $1.02 cents, about 1.8 percent, at to $59.35 a barrel on the New York Mercantile Exchange.
The prospects for higher interest rates, a slowdown in economic growth and Greece's travails have slowed a market that rose 47 percent between 2011 and 2013.
"The returns we've all had in the past three to five years are in the rearview mirror," said analyst John Fox, director of research at Fenimore Asset Management in Cobleskill, New York. "Things are pretty flat, which makes sense after 2013 and 2014. Our stocks are trading at 100 percent fair value."
The S&P 500 ended down 0.2 percent since March 31. The index's advance sputtered as the Federal Reserve signaled that it intends to raise interest rates this year should the economy warrant it.
Stocks in the S&P 500 are up 200 percent since March 2009 as earnings doubled and companies bought back about $2 trillion of their stock. Now the gauge is mired in one of the tightest ranges in two decades, caught in a tug-of-war over whether the economy is strong enough to withstand higher borrowing costs and bolster corporate profits.
The S&P 500 drifted to an all-time high on May 21, before the Greece crisis overshadowed signs that a first-quarter slowdown in economic growth would prove transitory.
The benchmark index tumbled 2.1 percent Monday, the most since April 2014 and erasing gains for the year, as Greece surprised investors by shutting lenders and imposing capital controls after debt negotiations broke down.
The decline pushed the index within 5 points of its average price during the past 200 days. Stocks have only crossed the level once since 2012 -- the period of last October's sell-off, which gave way to an 11 percent advance at the end of 2014.
"We're getting a little relief from yesterday's sell-off, but investors are still reluctant to commit capital," said analyst Bill Schultz, who oversees $1.2 billion as chief investment officer at McQueen, Ball & Associates Inc. in Bethlehem, Pennsylvania. "While people may downplay the contagion effect, there's still uncertainty out there."