WASHINGTON—Congress is taking aim at China in a must-pass defense-policy bill at the same time that the Trump administration is seeking to negotiate an interim trade pact with Beijing.

House and Senate Republicans and Democrats have reached agreement on language in the National Defense Authorization Act that would bar the use of federal funds to buy Chinese buses and railcars, congressional aides familiar with the matter told The Wall Street Journal, adding that the ban excludes pre-existing contracts.

The...