The trade deficit narrowed marginally in August, but the trade gap with China widened to a record high, the Commerce Department said on Thursday.

The trade gap totaled $45.61 billion, down slightly from a revised $45.63 billion in July. Analysts had expected the deficit to widen to $45.8 billion in August.

U.S. exports fell 0.1 percent to $177.61 billion, but total imports were about flat.

Imports from China rose to $37.4 billion, the highest on record and pushed the monthly U.S. trade deficit with the Asian manufacturing giant to a record $29.0 billion.

The eye-catching figures come just days after the Senate passed legislation to crack down on Chinese currency practices, which many lawmakers blame for the huge trade gap.

The bilateral deficit with China totaled $189.3 billion through the first eight months of this year, compared with $173.5 billion in the same period last year.

(Reporting by Jason Lange, Editing by Chizu Nomiyama)