The two companies are so close that Apple is likely to gain, and keep, the top spot soon.
Apple shares gained 5.9 percent to $374.01 on Tuesday, bringing its market capitalization to about $347 billion.
Exxon Mobil's stock, meanwhile, closed up 2.1 percent at 71.64.
That gives the oil company a market cap of $348 billion as of the market's close. Its stock retreated earlier in the day, allowing Apple to take the lead.