Senators confirmed Rep. Mick Mulvaney (R-S.C.) to lead the Office of Management and Budget in a narrow vote Thursday morning, giving the congressman one of the most powerful positions in President Trump's Cabinet and the responsibility of reconciling the new administration's conflicting spending priorities.

The Senate confirmed Mulvaney by a vote of 51-49. No Democrats cast votes in favor of Mulvaney, and Sen. John McCain (R-Ariz.) defected, voting with the Democrats against the nominee.

In a speech on Wednesday, McCain said that he and Mulvaney could not agree on spending on the military. McCain favors an expanded budget for the Pentagon, while Mulvaney advocates reductions.

“We must rebuild our military while at the same time putting our nation on a sustainable long-term fiscal path. We can and must do both,” McCain said. “Unfortunately, Congressman Mulvaney has spent his last six years in the House of Representatives pitting the national debt against our military.”

Elected to Congress in the tea party movement of 2010, Mulvaney has established a reputation as a doctrinaire advocate of limited government who opposes federal expenditures even on programs with broad bipartisan support, such as relief for victims of natural disasters, if that relief is not paid for by savings in other areas of the budget. Liberal senators hectored Mulvaney for supporting drastic reductions in Social Security and Medicare.

Mulvaney now reports to the president, who has pledged to spend more on the military, public works and a wall along the Mexican border. Trump has also said he will maintain current benefits from Social Security and other entitlements.

As director of the Office of Management and Budget, Mulvaney will confront difficult decisions about how to pay for a replacement of the Affordable Care Act, President Obama's health-care reform policy. President Trump has promised to repeal Obama's law and find another way to provide for health insurance for the millions of Americans who cannot afford it on their own, which will likely be expensive.

As Mulvaney prepares to help Trump achieve his immediate goals, the national debt continues to accumulate. The pace of federal borrowing increased again last year for the first time since the beginning of the Obama administration.

Analysts say a fiscal crisis is unlikely for decades to come, but most agree that the country's current borrowing is unsustainable. Last month, the nonpartisan Congressional Budget Office projected that the federal debt will equal the size of the economy in 15 years. The office noted that an aging population will contribute less in income and payroll taxes while drawing more on entitlements such as Social Security and Medicare.

Mulvaney has advocated wholesale changes to these programs. He voted in favor of the budget proposed by the Republican Study Committee two years ago, which envisioned reducing spending on Social Security by $188 billion over 10 years and spending on Medicare by $216 billion over the same period.

“We have to end Medicare as we know it,” Mulvaney told Fox Business Network in 2011, three months after he was sworn in as a congressman.

In his opening statement opposing Mulvaney at the confirmation hearing last month, Sen. Bernie Sanders (I-Vt.) noted Trump's support for protecting entitlements.

“One of the cornerstones of his campaign was that he was not going to cut Social Security, Medicare and Medicaid. He wasn’t ambiguous about this,” Sanders said of Trump. “It does not make sense to me to have a key adviser to the president having views directly in opposition to what the president campaigned on.”

Mulvaney responded that he was only being honest about the programs' financial situation, and that he would continue to advocate for reforms in the White House.

“The credibility that I think I bring to this job is that I believe very firmly in real numbers,” Mulvaney told the committee. “My job is to tell the president the truth.”

Mulvaney also received criticism from Democrats for failing to pay taxes for a household employee between 2000 and 2004. Sen. Charles E. Schumer (D-N.Y.), the minority leader, called the omission “disqualifying,” noting that nominees for the cabinet in past administrations had withdrawn from consideration when unpaid taxes were revealed.

The opposition from McCain and the Democrats is the latest instance of unusually tepid support for Trump's nominees in the Senate. Opposition from Democrats and several Republicans forced Andrew Puzder, the president's pick for labor secretary, to withdraw his name on Wednesday. When a few Republicans defected to vote against Education Secretary Betsy DeVos, Vice President Pence was forced to cast a vote breaking a tie to confirm her.