WASHINGTON — In four weeks, lawmakers could be heading into the midterm elections with a newly adopted federal budget and a sense of pride for finishing their work on time.

Or they could be heading home with a short-term budget extension and a lot of angry voicemails from Pentagon leaders complaining about their long-term budget plans.

Or they could be stuck in town dealing with a partial government shutdown, a potential political disaster as voters head to the polls.

Given the stakes, the appropriations issue will dominate Congress’ September session. Party leaders have said in recent days they are cautiously optimistic that they can finish a substantial portion of the work by the Sept. 30 deadline.

Of course, they have been optimistic in past years, too, and usually unsuccessful. Congress has passed just one of its 12 annual appropriations measures on time in the last eight years (the Veterans Affairs budget for fiscal 2017) and hasn’t finalized all of its appropriations work on time since fiscal 1997.

But Senate lawmakers in August did manage to advance a complicated “minibus,” including money for the departments of defense, health and human services, labor and education, setting up the chance for those agencies to see their budget’s finalized on time this year.

Senate Majority Leader Mitch McConnell, R-Ky., said the move puts Congress “on a pathway to avoid an omnibus or any kind of drama associated with the end of the fiscal year.”

Lesser of two evils

When lawmakers have been unable to meet budget deadlines, they have typically adopted a continuing resolution to extend existing spending levels until a full-year funding deal can be reached.

Defense Department officials have long complained those stopgap budget measures hurt their procurement schedules and new program starts, since they delay anticipated funding increases.

But Congress sees those short-term fixes as preferable to the alternative: another government shutdown. Funding fights have forced two short shutdowns this year, but also shuttered federal offices for nearly three weeks in 2013.

Throughout the summer, President Donald Trump has hinted that he may force a partial government shutdown if Democrats don’t go along with his plans of increased funding for a security wall along the southern U.S. border.

Congressional Republicans have tried to downplay those threats and keep both sides on finding a final compromise in the next few weeks.

“We’ve got a month to go, and my concern right now is getting the House back, where we can start working face-to-face and try we can resolve some differences between our bills,” said Senate Appropriations Chairman Richard C. Shelby, R-Ala., adding that an impasse is “looming out there.”

Sen. Dick Durbin, the top Democrat on the Senate’s Defense Appropriations subcommittee and Senate’s No. 2 Democrat, warned Trump that such a move would symbolize Washington dysfunction and alienate midterm voters.

“I don’t think the president understands the damage that would be done if he shuts down the government over any issue, let alone the border wall,” Durbin said. “If he is foolish enough to do that and the Republican leadership can’t convince him otherwise, there will be a price paid.

Let’s make a deal

There have been staff-level negotiations on spending bills in recent weeks, but lawmakers made clear nothing would be final until the House returns from its recess next week.

At least one package in the queue: the Energy-Water/Legislative Branch appropriations package could be voted on in coming days.

The Military Construction/Veterans Affairs budget bill has stalled over a $1.6 billion funding gap, which White House officials want covered through other programming cuts and Democrats want covered with emergency spending.

“We think we have a way, but we haven’t crystalized it with the other side yet,” Shelby said Tuesday, without offering further details.

The defense appropriations bill is unlikely to move forward until most of those domestic spending issues are settled.

When the House returns, House Speaker Paul Ryan expects the focus to be on three “minibus” packages, according to his spokesperson, and for the House to go to conference with the Senate on its package of defense appropriations with spending for the departments of Labor, Health and Human Services.

Republicans have expressed skepticism about the Senate’s packaging of defense with non-defense spending. But splitting them would likely be a deal-breaker for Democratic leaders.

Still, Shelby said he believes that finding a path forward won’t be as difficult as in years’ past. Just last spring, leaders from both parties agreed upon a two-year spending plan outlining the top line spending goals for fiscal 2019. The remaining appropriations work is just sorting out the details.

“I would hope their goal is to fund the government, because it’s not in the interest of Democrats and Republicans in the House to lurch from crisis to crisis, and here’s the election coming up,” he said. “We’ll see what happens.”

And McConnell said last week that he has been pleased with the process thus far.

“I think, given how completely fouled up the government funding process has been for 20 years, our Democratic colleagues in the Senate are to be commended for cooperating with us,” McConnell said.

“This is about omnibus prevention, about actually demonstrating to the American people that we can do what we’re supposed to do on time.”