WASHINGTON (AP) — Congressional bargainers traded offers and worked toward a border security compromise Friday that would avert a fresh federal shutdown and resolve a clash with President Donald Trump that has dominated the opening weeks of divided government.

Both sides' negotiators expressed optimism that an accord could be reached soon on a spending package for physical barriers along the Southwest border and other security measures. Participants said the agreement would all but certainly be well below the $5.7 billion Trump has demanded to build his proposed wall, and much closer to the $1.6 billion that was in a bipartisan Senate bill last year.

"That's what we're working toward," said Rep. Lucille Roybal-Allard, D-Calif., one of the bargainers.

Besides the dollar figure, talks were focusing on the type and location of barriers, participants said. Also in play were the number of beds the federal Immigration and Customs Enforcement agency could have for detained migrants, and how much aid for natural disaster relief would be included.

Money for high-tech surveillance equipment and more personnel was also expected to be included.

No one ruled out that last-minute problems could emerge, especially with Trump's penchant for head-snapping turnabouts. But the momentum was clearly toward clinching an agreement that Congress could pass by next Friday. The next day, many government agencies would have to close again for lack of money, if no deal is reached.

Negotiator Rep. Chuck Fleischmann, R-Tenn., said the latest Democratic offer was "much more reasonable." And Democratic bargainer Rep. Pete Aguilar of California said, "Each time an offer and a counter is going back and forth the number of open items is reducing. That is progress."

Rep. Mark Meadows, R-N.C., who leads the hard-right House Freedom Caucus, said he spoke Thursday night to Trump, who he said was in "wait and see" mode. Meadows said he expects an agreement to provide something closer to $1.6 billion.

"I'm not optimistic it'll be something the president can support," Meadows said.

A conservative House GOP aide said to back a deal, Freedom Caucus members wanted at least $2 billion for barriers and no restrictions on new construction, land acquisition or new types of barriers that could be built.

The aide also said the agreement need not contain the term "wall" — a word that was a premier plank of Trump's presidential campaign, and which Trump has lately alternated between embracing and abandoning. The person would talk only on condition of anonymity to describe private talks.

Meadows' assessment of Trump's view clashed with one expressed Thursday by Sen. Richard Shelby of Alabama, the chief GOP bargainer.

He described the emerging deal to Trump in the Oval Office and told reporters the session was "the most positive meeting I've had in a long time." Shelby said that if the final agreement followed the outline currently under discussion, he believed Trump "would sign it."

Trump has modest leverage in the battle. Besides facing unified Democratic opposition, there is virtually no GOP support in Congress for another shutdown.

When congressional talks began, Trump called them a "waste of time."

"They've got to come to a solution that actually does what they promised they would do, which is protect the American people," White House spokesman Hogan Gidley said on Fox News.

Trump faces an aggressive, Democratic-led House that is ramping up investigations into Russian involvement in his campaign and businesses and trying to get access to his income tax returns. But ending the border security fight would close one chapter that's bruised him, including his surrender after a 35-day partial federal shutdown that he started by unsuccessfully demanding taxpayer money to build the border wall.

Even with a deal, it was possible Trump might try using claims of executive powers to reach for more wall funding. That could spark votes by Congress to block him, which Trump could veto but would still inflict political damage.

Sen. Lindsay Graham, R-S.C., said Thursday that an accord could be "a good down payment" and added, "There are other ways to do it and I expect the president to go it alone in some fashion." Acting White House Chief of Staff Mick Mulvaney said on Fox News Channel's "Hannity" on Wednesday, "If Congress won't participate or won't go along, we'll figure out a way to do it with executive authority."

Members of both parties have expressed opposition to Trump bypassing Congress by declaring a national emergency at the border, a move that would be certain to produce lawsuits that could block the money.

Lawmakers have grown accustomed to expecting the unexpected from Trump. Before Christmas, both parties' leaders believed he'd support a bipartisan deal that would have prevented the recently ended shutdown, only to reverse himself under criticism from conservative pundits and lawmakers.

"There's a small light at the end of the tunnel," said Sen. Pat Roberts, R-Kan. "We just hope it's not a train coming the other way."

Online Public Information File

Viewers with disabilities can get assistance accessing this station's FCC Public Inspection File by contacting the station with the information listed below. Questions or concerns relating to the accessibility of the FCC's online public file system should be directed to the FCC at 888-225-5322, 888-835-5322 (TTY), or fccinfo@fcc.gov.