At the same time, the U.S. trade deficit with China hit a record high.
Economists say the latest numbers could influence the Trump administration to carry out its "America First" trade policies more aggressively.
The administration's protectionist policies have left the United States in disputes with the European Union, Canada, Mexico and China. President Donald Trump says the United States is being used by its trading partners.
The U.S. Commerce Department reported the rise in the trade deficit Wednesday. Its report came a day before the end of a public comment period about a list of $200 billion worth of Chinese goods. The U.S. government is expected to announce tariffs on those products.
"America still isn't getting a fair deal on trade and that can only mean one thing," said Chris Rupkey, chief economist at the MUFG financial group in New York.
"President Trump is going unleash another $200 billion in tariffs on China imports," he said.
The Commerce Department report said the trade deficit increased 9.5 percent to $50.1 billion in July. This happened as exports of soybeans and civilian aircraft dropped, while imports hit a record high. The trade deficit has now widened in each of the past two months.
The government announced import duties on goods including steel, aluminum, washing machines and solar panels earlier this year. It said the move was to protect American industries from what Trump says is unfair foreign competition.
The United States and China each have put retaliatory tariffs on a combined $100 billion worth of products since early July.
The Trump administration also wants to rework the North American Free Trade Agreement. The United States struck a deal with Mexico last week, but negotiations with Canada have been difficult.
The administration says ending the trade deficit will put the economy on a path of faster growth. But economists say some of the government's policies, such as a $1.5 trillion tax cut earlier this year, will worsen the trade deficit.
The trade deficit narrowed in April and May as farmers increased soybean exports to China before its tariffs on American products came into effect in early July.
Record high imports
After considering inflation, the trade deficit increased to a five-month high of $82.5 billion in July from $79.3 billion in June.
The goods trade deficit with China grew 10 percent to a record $36.8 billion in July. The trade gap with Mexico dropped 25.3 percent to $5.5 billion while the gap with Canada rose 57.6 percent to $3.1 billion. The trade deficit with the European Union rose 50 percent to a record high of $17.6 billion.
In July, U.S. exports of goods and services fell one percent to $211.1 billion. However, imports of goods and services increased 0.9 percent to a record $261.2 billion. They were helped by imports of computers and computer parts. Total imports were higher, in part, thanks to petroleum imports, which were the highest since December 2014 because of higher oil prices.
I'm Caty Weaver.