WASHINGTON — A broad bipartisan group of senators reached agreement Wednesday on a narrow rewrite of the nation’s immigration laws that would bolster border security and resolve the fate of the so-called Dreamers, even as President Trump suggested he would veto any plan that does not adhere to his harder-line approach.

Their compromise legislation sets up a clash pitting the political center of the Senate against Mr. Trump and the Republican congressional leadership.

Senators in both parties have been racing against a self-imposed end-of-the-week deadline to write legislation that could win wide support by increasing border security while at the same time offering a path to citizenship for young immigrants brought to the United States illegally as children.

Members of the bipartisan group, which calls itself the Common Sense Coalition, said their deal does just that. They were working Wednesday evening to determine whether their bill could garner the 60 votes necessary to break a filibuster.