(Reuters) - Financial markets are fretting about the fiscal situation in Washington, with deadlines looming in late September and early October on the U.S. budget and the federal debt ceiling. Republican President Donald Trump stoked anxieties by threatening on Aug. 22 to shut down the government if Congress does not fund his U.S.-Mexico border wall. Here is what you need to know about the budget and the debt ceiling, separate issues but ones that are politically connected: Congress is supposed to pass annual spending bills around the end of the federal fiscal year on Sept. 30 to fund most of the U.S. government, but disagreements often prevent this. When that happens, lawmakers usually pass a temporary bill extending current spending levels with no changes for days, weeks or months, while they work on a long-term agreement. When even a short-term budget patch cannot be agreed in Congress, or if the president decides to veto either a long-term or short-term budget measure, the government shuts down.  This year, when Congress returns on Sept. 5 from its long summer recess, lawmakers will have only about 12 working days to pass a budget measure, probably a short-term patch, known as a continuing resolution, to keep the government open. If a budget measure is not passed before Oct. 1, or if Trump vetoes a budget deal over his Mexican border wall demand, portions of the government will begin to shut down and non-essential employees will go without pay until an agreement is reached. The last time the government shut down, in October 2013 for about two weeks, was because of a dispute over funding for former Democratic President Barack Obama’s healthcare law. There were three shutdowns in the 1990s, the longest lasting 21 days. In the 1970s and 1980s there were 14 shutdowns, most brief and some only partial. Shutdowns hurt federal workers, rattle financial markets and shake confidence in the U.S. government abroad, but to date they have done little lasting economic damage, according to analysts. The “debt ceiling” is a legal cap on how much money the U.S. government can borrow through bonds and other debt issued by the U.S. Treasury. It now stands at about $19.8 trillion, very close to the actual national debt.  Since March, the Treasury has been using financial “extraordinary measures” to stave off hitting the ceiling. Once the ceiling is hit, Congress must raise it. If it does not, the government cannot keep borrowing. This matters because the government spends more than it collects in taxes. That accounts for the federal budget deficit. So Washington continually borrows money to cover its bills. The Treasury has said that Congress must increase the debt ceiling by Sept. 29. However, default likely could be staved off a few more weeks by extraordinary measures, analysts said.  In any case, legislation to raise the debt limit will need to be adopted, at the very latest, by mid-October, they said. If the debt ceiling is not raised and the government can no longer pay its bills, default results, along with a likely downgrade in the U.S. credit rating. Political gridlock has never led to the United States’ reaching its debt ceiling and its bills going unpaid, but there have been some close calls. A standoff in August 2011 cost the country its top-notch bond rating from the credit ratings agency Standard & Poor’s and caused the most jarring two weeks in financial markets since the 2007-2009 global financial crisis. The two move on separate tracks, but are likely to get tangled, with Republican opponents of increasing the debt ceiling probably demanding federal spending cuts. Some analysts said Congress may try to tackle both issues at the same time, perhaps in a single piece of legislation. Both the spending and debt ceiling bills can pass the Republican-led House of Representatives by a simple majority vote. But in the Senate, where Republicans hold 52 of 100 seats, 60 votes are needed to pass, meaning the bills will need some Democratic support.  Trump made his U.S.-Mexico border wall a central promise of his 2016 presidential campaign. He also promised that Mexico would pay for it, but Mexico has steadfastly refused to do so and Trump has largely stopped talking about that pledge. Conservative House Republicans agree with the president on the need for a wall and say border-wall funding should be a priority in any spending legislation. Some have already indicated they are willing to shut down the government to get it. Moderate Republicans have called a shutdown unwise, and Republican leaders are determined to prevent one, fearing it would worsen doubts about the party’s ability to govern. Democrats are uniformly opposed to Trump’s wall and say any blame for a shutdown would rest solely with Republicans. The Trump administration reversed course earlier this month and said it would back a “clean” raising of the debt ceiling, meaning it would not be tied to other policy measures. Democrats and moderate Republicans also support a clean debt-ceiling increase. But conservative Republicans, especially in the House, often use debt-ceiling legislation to insist on changes to spending, making them opposed to a clean bill. 
Factbox: What are the U.S. budget, debt limit issues spooking markets?