The Senate confirmed President Obama’s picks Friday for key roles with the Internal Revenue Service and the Department of Homeland Security, bringing new blood to two agencies that experienced troubled years in 2013.

Formerly retired turnaround specialist John Koskinen will head the IRS, while U.S. immigration director Alejandro Mayorkas will take on the No. 2 role at Homeland Security.

The IRS is working to regain public trust after inspector general probes revealed that the agency had spent lavishly on a 2010 conference in Anaheim and used inappropriate criteria for screening advocacy groups, mostly conservative organizations, during the 2010 and 2012 election cycles.

Koskinen won a five-year term as IRS commissioner after the Senate voted 59 to 36 to confirm him. His nomination garnered bipartisan support, but some Republicans wanted the vote to wait until congressional and Justice Department investigations into the agency’s screening controversy conclude.

As for Homeland Security, the department is trying to deal with long-standing morale problems.  The department placed dead last for the second straight year among large organizations in the Best Places to Work in the Federal Government report, an annual ranking of job satisfaction among federal agencies. It’s overall score also declined for the third consecutive year.

Leadership vacancies have been a persistent problem for the decade-old DHS during the Obama administration, with 40 percent of the top positions either unfilled or held by acting officials. The Senate confirmed Jeh Johnson on Monday to become the department’s new secretary.

Mayorkas’s confirmation process sharply divided Democrats and Republicans, and the Senate voted along party lines to confirm him.

The new deputy secretary is the subject of an ongoing investigation by the Homeland Security inspector general into allegations that he helped secure foreign-worker visas on behalf of a politically connected firm with ties to Virginia Gov.-Elect Terry McAuliffe (D) and Anthony Rodham, a brother of former Secretary of State Hillary Clinton.

Mayorkas denied wrongdoing during a July congressional hearing, saying he only met with McAuliffe for a general discussion about the pace of visa processing.

Republicans had called for a delay in Mayorkas’s confirmation vote until the inspector general’s office wraps up its investigation, which is expected conclude in February.

In a statement following Friday’s vote, Senate Homeland Security Committee Chairman Tom Carper (D-Del.) made no indication that he is concerned about Mayorkas’s past. “Director Mayorkas has convinced me that he is highly qualified for the job, and I am confident that he can help lead the department during this challenging period,” he said.

The National Hispanic Leadership Agenda, a coalition of Latino organizations, applauded the Senate’s vote, which made Mayorkas one of the highest-ranking Latino appointees to be confirmed for Obama’s second-term administration.

“The upcoming year will be especially critical for Latino and immigrant communities as we continue to press forward our call for solutions to help ease the hardships felt by our nation’s broken immigration system,” NHLA executive director Hector Sanchez said in a statement.

The Senate is expected to vote on another key nominee, Janet Yellen, whom Obama tapped to chair the Federal Reserve, on Jan. 6.

Follow Josh Hicks on TwitterFacebook or Google+. Connect by e-mail at  josh.hicks@washpost.comVisit The Federal Eye, The Fed Page and Post Politics for more federal news. E-mail with news tips and other suggestions.