WASHINGTON -- President Donald Trump will emerge from the longest government shutdown in U.S. history politically weakened, his reputation questioned and his signature campaign promise still glaringly unfulfilled.

The 35-day partial shutdown over the president's demand for billions of dollars to build a wall along the U.S.-Mexico border was, in the end, futile. Facing defections within his own party, sagging poll numbers and public criticism for interrupted services, the self-proclaimed master dealmaker accepted an agreement that he had previously spurned and set an ignominious record that will remain part of his legacy. Days after Trump marked the midpoint of his term, the shutdown highlighted the disquieting side effects of his unconventional governing style and the trials that lie ahead for him in dealing with emboldened Democrats.

The folly of the effort was readily apparent inside the White House, where aides had warned Trump even before the shutdown began that there was no avenue to success in the showdown with Capitol Hill. Democrats ran for office on preventing Trump from building the wall — and it's hardly a popular idea even among Republican lawmakers. Advisers watched in shock as Trump declared in a December meeting with lawmakers that he would be "proud" to shut down the government.

And when he ultimately did just that, they feared the messaging war had already been lost.

"He was playing double-A ball against major leaguers," said former Republican Rep. Tom Davis of Virginia, who once headed the House GOP's campaign arm. By backing himself into the shutdown with no way out, Davis said, Trump displayed a lack of discipline from the start.

The strategic deficit was only magnified by what allies saw as tactical errors. Trump spent the holidays tweeting from the White House rather than making public appearances to showcase his readiness to negotiate. He didn't deliver a public address or visit the border to make his case until weeks had already gone by. Perhaps most crucially, he underestimated House Speaker Nancy Pelosi and the unity of congressional Democrats, thinking the Californian would be more amenable to a deal on the wall once she won the speakership.

Trump's message zigzagged sometimes by the hour. He maintained he was proud of shutting down the government and then tried to pin the blame on Democrats. One moment he signaled he was ready to concede the wall in favor of other barriers on the border, and the next he tweeted he was fighting for the wall as strongly as ever. It was emblematic of the dysfunctional White House culture he has fostered and the challenges that have been manifest on decisions big and small for two years.

By the end of the shutdown, West Wing aides and outside allies of the president began to look at the seminal promise of Trump's 2016 campaign as an immense — and unachievable — burden on his presidency.

It was complaints that Trump appeared to be passing up his last, best opportunity to make good on his build-the-wall pledge that led Trump into the shutdown to begin with. Conservative commentators and House Freedom Caucus members fired off warnings that Trump's base would sour on him if he didn't use the last days of unified GOP control of Washington last year to try to get money for the barrier.

But in his quest to appease his base, the president tarnished his standing with the American public. Overall, 34 percent of Americans approve of Trump's job performance in a survey released this week by The Associated Press-NORC Center for Public Affairs Research. That's down from 42 percent a month earlier and nears the lowest mark of his two-year presidency.

"Hopefully now the president has learned his lesson," Senate Democratic leader Chuck Schumer said in a press conference with Pelosi.

The impasse was an early test for Pelosi after her return to the speakership, one that she appeared to pass handily. Democrats remained unified against White House efforts to divide the caucus, and they head into the next round of debate over border security funding determined to make good on their own 2018 promises to block Trump's wall.

As White House aides suggested that the shutdown had brought Democrats to embrace border "barriers," Pelosi made clear her party remained resolved against the wall.

"Have I not been clear?" she said. "No, I have been very clear."

Trump, characteristically, refused to concede that he'd conceded. Instead, he insisted he hadn't caved to Democrats, and he threatened yet another shutdown even while bemoaning the last one's impact on Americans.

"This was in no way a concession," Trump tweeted late Friday. "It was taking care of millions of people who were getting badly hurt by the Shutdown with the understanding that in 21 days, if no deal is done, it's off to the races!"

———

Associated Press writer Alan Fram contributed to this report.

———

EDITOR'S NOTE: Zeke Miller has covered the White House and politics in Washington since 2011. Follow him at http://twitter.com/zekejmiller