The S&P 500, Dow and Nasdaq all rose after the US markets opened on Wednesday morning, reversing a sharp decline during overnight trading following an Iranian missile attack on two military bases in Iraq that house U.S troops.
The S&P index recorded 59 new 52-week highs and one new low, while the Nasdaq recorded 91 new highs and 21 new lows. The Dow Jones Industrial Average gained 0.8 percent but remained below the all-time high set on January 2nd.
The technology-heavy Nasdaq Composite Index closed up 0.7 percent at 9,129.
Defense stocks, which have had a hot start to the year amid the escalating tensions with Iran, gained further ground.
Investors have been on edge since a surprise US airstrike last week that killed leading Iranian general Qassem Soleimani.
The spotlight will next move to Friday's labor report, and economists expect it to show employers added 160,000 jobs last month.
Investors snapped up market heavyweights including Apple Inc, Microsoft Corp, Amazon.com Inc, Alphabet Inc and Facebook Inc, lifting their shares between 0.9 per cent and 2.0 per cent.
"The main market driver right now is the generally improving macroeconomic backdrop and most other things are a distraction from that overriding theme", Michael Reynolds, investment strategy officer at Glenmede, said by phone.
The S&P 500 headed for a fresh record after Trump said Iran appeared to be "standing down", and announced more sanctions on the country.
The S&P 500 fell 9.35 points, or 0.3%, to 3,265.35.
After a better-than-expected private payrolls report on Wednesday, investors are awaiting Friday's jobs report as well as fourth-quarter reports.
YIELDS: The yield on the 10-year Treasury fell to 1.85% from 1.87% late Wednesday. Microsoft rose 1.3% and Goldman Sachs rose 1.2%.
Alphabet Inc and Facebook Inc rose 0.8% and 0.5%, respectively.
Market participants are also likely to closely monitor a flurry of speeches from policymakers at the United States central bank. France's CAC 40 added 0.2% to 6,045.
The greenback gained against major currencies for a third straight day after jobless claims fell by more than expected, adding to signs of economic strength ahead of the USA payrolls report Friday.
West Texas Intermediate crude oil, the us benchmark, was 0.3 percent lower at $59.45 a barrel after plunging almost 5 percent the previous day.
Gold fell $5.70 to $1,551.70 per ounce as investors felt less need for safety. Brent crude, the global standard, fell 7 cents to end at $65.37 a barrel.
Smaller rival J.C. Penney Co Inc tumbled 11.3% after disappointing same-store sales numbers.