WASHINGTON — Record imports drove the U.S. trade deficit up for the third straight month in August. The deficit in the trade of goods with China and Mexico hit records.

The Commerce Department said Friday that the trade gap — the difference between what America sells and what it buys abroad — rose to $53.2 billion in August from $50 billion in July. The August reading was the highest since February.

Imports rose 0.6 percent to a record $262.7 billion on higher shipments of cell phones and autos; exports slid 0.8 percent to $209.4 billion.

The United States ran a $76.7 billion deficit in the trade of goods such as machinery and cars. That gap was partially offset by a $23.5 billion surplus in the trade of services such as banking and tourism.

President Trump campaigned on a pledge to bring down U.S. trade deficits and has slapped taxes on imported steel, aluminum and on many Chinese products, drawing retaliatory tariffs from U.S. trading partners.

MBA BY THE BAY: See how an MBA could change your life with SFGATE's interactive directory of Bay Area programs.

Trump’s sanctions have yet to have an impact on the deficit, which is up 8.6 percent this year to $391.1 billion. The goods deficit with China rose 4.7 percent in August to a record $38.6 billion; and the gap with Mexico widened 56.9 percent to $8.7 billion, also a record.

Trump sees the lopsided trade numbers as a sign of U.S. economic weakness and as the result of bad trade deals and abusive practices by U.S. trading partners, especially China.

In addition to imposing import taxes, he has pulled out of an Asia-Pacific trade deal negotiated by the Obama administration and forced the rewriting of the North American Free Trade Agreement with Canada and Mexico.

Mainstream economists view trade deficits as the result of an economic reality unlikely to bend to changes in trade policy: Americans spend more than they produce, and imports fill the gap. The strong U.S. economy also encourages Americans to buy more foreign products.

U.S. exports are also hurt by the American dollar’s role as the world’s currency. The dollar is usually in high demand because it is used in so many global transactions. That means the dollar is persistently strong, raising prices of U.S. products and putting American companies at a disadvantage in foreign markets.

Paul Wiseman is an Associated Press writer.