WASHINGTON — The Senate Thursday confirmed President Donald Trump’s pick to run the White House budget office, giving the Republicans’ tea party wing a voice in Trump’s Cabinet.

South Carolina Rep. Mick Mulvaney squeaked through the Senate on a 51-49 vote. Armed Services Committee Chairman John McCain, who’s emerging as perhaps the most vocal critic of the Trump administration, opposed Mulvaney for past House votes supporting cuts to Pentagon spending.

‘‘Mulvaney has spent his last six years in the House of Representatives pitting the national debt against our military,’’ McCain said.

Mulvaney’s confirmation promises to accelerate work on Trump’s upcoming budget plan, which is overdue. That’s typical at the beginning of an administration. But there is also the need to complete more than $1 trillion in unfinished spending bills for the ongoing budget year, as well as transmit Trump’s request for a quick start on his oft-promised U.S.-Mexico border wall and tens of billions of dollars in emergency cash for the military.

Get Ground Game in your inbox:

Daily updates and analysis on national politics from James Pindell.

In the past, Mulvaney has routinely opposed such catchall appropriations bills, which required Republicans to compromise with former President Barack Obama, but the upcoming measure is going to require deals with Democrats

The South Carolina Republican brings staunchly conservative credentials to the post, and Trump transition officials have telegraphed he’s likely to seek big cuts to longtime GOP targets such as the Environmental Protection Agency and other domestic programs whose budgets are set each year by Congress.

Trump has indicated, however, that he not interested in tackling highly popular benefit programs like Social Security and Medicare and wants a major investment in infrastructure programs like highways.

Democrats opposed Mulvaney over his support for curbing the growth of Medicare and Social Security and other issues, such as his brinksmanship as a freshman lawmaker during the 2011 debt crisis in which the government came uncomfortably close to defaulting on U.S. obligations.

‘‘He said to me in a one-on-one meeting how he would prioritize the debts he would pay if he defaulted on the debt,’’ said Sen. Claire McCaskill, D-Mo. ‘‘Wouldn’t that be a great addition to the chaos we are all feeling right now?’’

The vote came a day after Trump’s pick to head the Labor Department, Andrew Puzder, abruptly withdrew his nomination in the face of Republican opposition. Puzder faced questions over taxes he belatedly paid on a former housekeeper not authorized to work in the United States.

Mulvaney has managed to survive questions about his failure to pay more than $15,000 in payroll taxes for a nanny more than decade ago. He has since paid the taxes.