As the midnight Friday deadline loomed for a possible government shutdown, and politicians continued their rhetorical war of words, a larger message went out to the rest of the country: Washington is still broken.

The deal announced less than 90 minutes before the deadline may produce a sense of relief that the government will remain open. But given the tortured negotiations and the claims and counterclaims that were traded all day, the public is likely to find fault with both political parties.

Public sentiment has been clear for weeks. Overall, the country prefers compromise to confrontation, stalemate and shutdown, according to the polls.

That’s why President Obama and Democratic and Republican leaders in Congress all stressed their determination to avoid such an outcome. All will claim a measure of credit for avoiding the worst.

But after they dragged the drama late into the night, it’s likely they understood there would be no winners politically from the first round of budgetary battles this year.

President Obama and the Democrats have themselves to blame for being in this predicament. Had they done their jobs last year, when Democrats had ample majorities in the House and Senate, the government would have been funded for the current fiscal year before Republicans assumed control of the House.

Once in the battle, Obama and his party felt pressure to show they heard the message that many Americans believe the government spends too much and that deficits are unsustainable. As a result, the president and congressional Democrats were forced to agree to much larger spending cuts than they had wanted, rather than appear resistant to popular will.

Republicans will express satisfaction over those concessions. But the GOP bears as much responsibility as the Democrats for stringing out this battle. Though the country as a whole favors compromise, polls show that a narrow majority of Republicans prefer to stand firm on the deficit, with tea party supporters even more adamant in that conviction.

Republicans were determined to show the country and especially their tea party followers that they were serious about cutting spending. House Speaker John A. Boehner’s (R-Ohio) statement that there was no daylight between him and the tea party was designed to hold his rambunctious caucus together.

But there is political risk in that position. The tea party’s apparent hold on the House leadership comes at a time of diminishing popularity for the movement. A new poll from the Pew Research Center showed that “slightly more disagree with the tea party than agree with the movement, a reversal in public evaluations from a year ago,” according to the center’s news release.

Beyond that, House Republicans used the funding bill to advance their agenda on social issues, including defunding Planned Parenthood. They argued that such “riders” are common on these kinds of measures, but the inclusion of these policy proposals not only complicated the negotiations but undermined the party’s focus on spending cuts and deficits, which proved so effective in the midterm elections last fall.

Both sides knew the dangers of letting the government shut down.

Unlike the 1995-96 battles between congressional Republicans and President Bill Clinton, when Republicans took a beating from the public for closing down the government, public opinion about how to assess blame is more evenly divided this time.

“Everybody loses” in the event of a shutdown, Republican pollster Whit Ayres said. “The Democrats are in control of the government, or at least two-thirds of it [the White House and the Senate]. So it’s hard for them to escape censure. Republicans will come in for their share of the blame. The entire government generally looks incompetent.”

Most recent polls showed the public relatively evenly divided on the question of who would be held responsible for a shutdown. A recent Washington Post poll found that 37 percent of the public said they would blame Democrats, 37 percent would blame Republicans and 15 percent would blame both.

As negotiations played out this week, Republicans put down a marker for the future with the release of a budgetary blueprint by House Budget Committee Chairman Paul Ryan (R-Wis.). The GOP believes the public will see it as evidence that the party is serious about dealing with the deficit and entitlement programs and that Republicans, rather than Obama, are leading the way to a solution.

But Democrats see Ryan’s proposal as creating new vulnerabilities for the Republicans.

Geoff Garin, a Democratic pollster, said that the public views the deficit as a serious problem and that voters are ready for tough action to deal with it, but only if the solutions are viewed as equitable.

“The Ryan budget is fundamentally out of sync with both the priorities and values of American voters today,” he said. “I think the flaws of Ryan’s approach are so substantial that they provide President Obama and Democrats a significant opportunity to hold the center in the budget debate.”

Both sides agree that this should have been an easy battle, or the battle that never occurred. Instead, Democrats and Republicans took the country — and government workers — to the brink, exposing vulnerabilities that will shape future negotiations and, depending on the result, the next election.

“This is all just leading to 2012 and what is going to be a seismic election,” said Ed Gillespie, former chairman of the Republican National Committee.

Republicans and Democrats face more difficult negotiations later this year over raising the debt ceiling and then a budget for the fiscal year that begins in October. The question is whether this clash has helped build relationships and mutual trust that will make those battles easier or whether it will embolden either side to dig in, hoping to gain ultimate political victory.