Wall Street shrugged off rising tensions in the Middle East on Monday, even as oil prices rose and stocks outside the United States sank.

The S&P 500 wobbled early but regained its losses and closed 0.4 percent higher for the day.

The resilience of the American market reflects, in part, the emergence of the United States as the world’s largest oil producer — and therefore, in part, a beneficiary of rising oil prices.

“The Middle East matters far less to the U.S. today than a decade ago,” Robert Bilkie, chief executive at Sigma Investment Counselors in Northville, Mich., wrote in an email.

But Monday’s rally also underscores ingrained investor expectations that the Federal Reserve will continue to take steps to bolster the economy and cushion financial markets.