For months, it seemed, nothing could deter investors who repeatedly sent stocks to record highs. But as fears spread that interest rates could finally begin to rise and as conflicts escalated in Ukraine, Iraq and Gaza, signs have emerged that investors finally may be getting anxious.

Those signals could be found in both the stock and bond markets this week. Stock prices have gyrated, while a measure of market volatility remained high and investors fled high-risk junk-bonds. Meanwhile, demand for low-risk government bonds have soared.

After a buoyant start to the summer, the U.S. stock market has seen some of its gains erased in the past few weeks. Despite gaining ground Friday, the Standard & Poor’s 500 has fallen 2.8 percent since it last reached a record high on July 24, and the Dow is now 3.4 percent below its last record close on July 16.

At the same time, investors pulled $16.4 billion from equity funds, including stock mutual funds, in the week that ended Wednesday, the highest stock outflow since February. In that same week, investors yanked a record-high $7.1 billion from high-yield junk-bond funds, according to the fund tracker Lipper. Junk bonds, often sold by companies with poor credit, pose high risk with the promise of high returns.

Analysts said these moves were undoubtedly connected to the rising geopolitical turmoil, which reached a crescendo Thursday night when President Obama announced he had authorized airstrikes on militants in Iraq.

“I do think there’s a little bit of nervousness out of there, I think people were concerned,” said David Seaburg, head of sales trading at Cowen and Co., though he said it was far from a panic situation.

Analysts also attributed investors’ anxiety to uncertainty over when the Federal Reserve will begin to raise the currently near-zero interest rates. The Fed has indicated that short-term interest rates will rise sometime next year, and it has slowed and will soon end its monthly bond purchases.

Many investors have turned to the low-risk government-bond market. The yields on U.S. 10- and 30-year bonds this week fell to their lowest levels since June 2013. Bond yields go down as prices go up.

The downward spike in yield is a signal that nervous investors were flocking toward safe-haven assets, analysts said.

“I’ve seen it with my own clients: If you put government guarantee on this thing, they will gobble it up,” said William Larkin, a fixed-income portfolio manager at Cabot Wealth Management.

Still, analysts said, investors are not simply selling risky stocks and replacing them with low-risk bonds. In many cases, investors are curating their portfolios, buying up shares in relatively low-risk, high-reward established companies, they said.

“There is a gravitation towards safety, but you can find safer trades within equity but that will actually give you a dividend yield,” Seaburg said. “You’re starting to see money moving around a little bit, which I think is a very healthy sign.”

And indeed, the U.S. stock markets concluded a disappointing week by rebounding Friday. While many European and Asian stock markets fell in Friday trading after the news that the United States might attack militants in Iraq, the S&P 500 and the Dow were both up more than 1 percent on the day.