U.S. investors were resilient in the face of renewed global worries Wednesday.
After bouncing around the breakeven for most of the day, stocks rallied into the early 1 p.m. ET close.
The Dow Jones industrial average, the S&P 500 and the Nasdaq ended up between 0.1 % and 0.3%.
Renewed political instability in Europe, violent clashes in Egypt and concerns about rising oil prices caused global markets to falter.
Oil prices topped $100 a barrel, the highest levels in more than a year, on fears that problems in Egypt could spread beyond its borders.
But economic numbers gave investors some reason for optimism. Jobs numbers were mostly better than expected, yet a weak manufacturing report raised concerns about economic growth.
U.S. markets will be closed Thursday in observance of Independence Day.
Click here for more on stocks, bonds, currencies and commodities
Preview to jobs Friday: Investors liked what the saw in the job numbers, mostly from the ADP's monthly figure on private-sector payrolls. These figures came in above expectations. First-time unemployment claims came in slightly below forecasts.
Still, investors are waiting for the big jobs numbers due out Friday. Economists surveyed by CNNMoney predict the U.S. economy added 155,000 jobs and the unemployment rate fell to 7.5% in June.
Related: Business hiring picks up
Europe... again?: Worries over the health of peripheral European countries once again caused global concerns.
Major European stock markets closed 1.3% lower, as investors worried that political turmoil in Portugal could re-ignite the region's debt crisis and a credit rating downgrade hit European banks. Asian markets also ended with losses.
"Portuguese political pandemonium continues today as austerity fatigue has led to the resignation of several key ministers and we could now be looking at the possibility of early elections," said Lee McDarby, head of corporate and institutional treasury dealing at Investec Bank.
Related: Investors still on edge: Fear & Greed in fear
Portugal's 10-year government bond yields hit 8% and the country's benchmark stock index shed more than 6% Wednesday after the finance minister stepped down and the foreign minister announced his resignation. Portuguese opposition parties are calling for an early election, though Prime Minister Pedro Passos Coelho insists he will not resign.
Credit rating agency Standard & Poor's downgraded three European banks -- Credit Suisse (CS), Deutsche Bank (DB) and Barclays (BCS) --- citing worries over the size of their investment banking portfolios and the impact of new regulations. Shares of Credit Suisse and Deutsche Bank closed lower, while shares of Barclays ended up.
The Obamacare fallout: The Obama administration's decision to delay implementing some parts of health care reform hit hospital stocks Wednesday. Shares of Tenet Healthcare (THC), HCA Holdings (HCA), Community Health Systems (CYH) and Health Management Associates (HMA) dropped between 2% and 4%.