WASHINGTON — A divided House voted on Tuesday to send $4.5 billion in humanitarian aid to the border to address horrific conditions facing a crush of migrants, attaching significant rules on how the money could be spent in the first action by Democrats to rein in President Trump’s immigration crackdown.

But the package — which passed by a vote of 230 to 195 nearly along party lines, only after Democratic leaders toughened restrictions on the money to win over liberal skeptics — faces a tough path to enactment. A similar measure with many fewer strings binding Mr. Trump has drawn bipartisan support in the Senate. And the House bill faces a veto threat from White House advisers, who regard the Senate bill as the surest way to speed the needed aid to strapped agencies dealing with the migrant influx.

Hours before the House bill passed, Mr. Trump said that he did not like some of the restrictions that lawmakers were seeking to place on the humanitarian funding, but that he badly needed the resources.

“There are some provisions, I think, that actually are bad for children,” Mr. Trump said in an interview for a coming book about his immigration policies. “There are a couple of points that I would like to get out of it, but I also have to get the money to be able to take care of children and families.”