The trade gap swelled more than 12 percent to $45.0 billion from a revised $40.1 billion in April, the biggest month-to-month increase in two years.
While the widening of the trade gap could prompt analysts to lower their estimates of second-quarter U.S. growth, the rise in imports points to firming underlying demand in the economy.
Imports rose 1.9 percent to $232.1 billion, the highest since the record level of $234.3 billion set in March 2012.
May imports, when adjusted for inflation, were a record $167.2 billion, the department said.
In another sign of improving domestic economic conditions, U.S. private employers stepped up hiring in June and new applications for unemployment benefits fell for a second straight week last week, pointing to improving labor market conditions.
Private payrolls increased 188,000 last month, the ADP National Employment Report showed Thursday. That compared to 134,000 jobs added in May. Economists had expected a gain of 160,000 jobs.
In a separate report, the Labor Department said initial claims for state unemployment benefits slipped 5,000 to a seasonally adjusted 343,000.
The four-week moving average of new claims, which is considered a better measure of labor market conditions, dipped 750 to 345,500.
The reports come ahead of the government's more comprehensive employment report on Friday.
"This is not really a big game changer, we don't expect any upside or downside surprise on Friday," said Sam Bullard, a senior economist at Wells Fargo in Charlotte, N.C. "Employment should slowly, gradually build momentum."
U.S. stock index futures pared losses, while U.S. Treasuries prices rose after the data. The dollar cut losses against the yen.
Nonfarm payrolls are expected to have increased 165,000 in June, according to a Reuters survey of economists, a touch below May's tally of 175,000 jobs. That would be higher than the monthly average of 155,800 during the past three months.
The unemployment rate is expected to fall a tenth of a percentage point to 7.5 percent. The employment report could shed fresh clues on the timing of the Federal Reserve's plan to start scaling back its monetary stimulus.
Fed Chairman Ben Bernanke said last month the U.S. central bank expected to trim its bond purchases later this year and halt the program by mid-2014, as long as the economy progresses as it expects.