Mike Pompeo
Mike Pompeo, a former Republican congressman from Kansas, replaces Rex Tillerson, the oil executive who was fired by Trump last month. / (Associated Press)

The Senate voted Thursday to confirm CIA chief Mike Pompeo as President Trump’s next secretary of state, ending a contentious nomination battle.

Pompeo was confirmed on a 57-42 vote.

All Republicans present voted to confirm Pompeo. Seven senators who caucus with the Democrats voted yes, including several in tight re-election contests, like North Dakota Sen. Heidi Heitkamp, West Virginia Sen. Joe Manchin and Indiana Sen. Joe Donnelly.

After the vote, Pompeo was sworn in by Supreme Court Justice Samuel Alito, a State Department spokesman said.

The Senate also confirmed Richard Grenell, Trump’s choice for ambassador to Germany whose nomination had been held up . Grenell, a former spokesman at the United Nations, was confirmed 56-42.

Grenell’s confirmation comes as German Chancellor Angela Merkel meets with the president at the White House on Friday.

Pompeo, a former Republican congressman from Kansas, replaces Rex Tillerson, the oil executive who was ousted by Trump last month.

“He will always put the interests of America first,” the president said in a statement after Pompeo’s confirmation. “He has my trust. He has my support.”

The Trump administration had pushed for lawmakers to confirm Pompeo by Thursday so he could head to a NATO meeting in Brussels on Friday.

A long list of pressing issues awaits him, including a decision on the Iran nuclear deal and Trump’s upcoming summit with North Korean leader Kim Jong Un, for which Pompeo laid the groundwork.

Trump, in early March, announced on Twitter that he had fired Tillerson and would be replacing him with Pompeo.

But the confirmation process has been rocky at times.

He barely avoided a rare rebuke Monday from the Senate Foreign Relations Committee after last-minute drama – but ultimately secured enough votes to be favorably recommended out of the committee.

There had been uncertainty ahead of that vote as most Democrats on the committee lined up against him. But after signaling they could oppose Pompeo in committee, two Republicans, Kentucky Sen. Rand Paul and Arizona Sen. Jeff Flake, both voted for him. And one Democrat relented to allow a favorable vote.

But the president lashed out at those opposing the nomination as “obstructionists.”

“Hard to believe Obstructionists May vote against Mike Pompeo for Secretary of State,” the president tweeted Monday. “The Dems will not approve hundreds of good people, including the Ambassador to Germany. They are maxing out the time on approval process for all, never happened before. Need more Republicans!”

Trump has already entrusted Pompeo with high-level diplomacy, sending him to North Korea over Easter weekend to meet with the rogue nation’s leader.

But Democrats, like New Jersey Sen. Bob Menendez, the foreign relations committee’s ranking member, accused Pompeo of a lack of transparency over the North Korea visit.

“I don’t expect diplomacy to be negotiated out in the open, but I do expect for someone who is the nominee to be secretary of state, when he speaks with committee leadership and is asked specific questions about North Korea, to share some insights about such a visit,” Menendez said.

When he fired Tillerson last month, Trump acknowledged he and his secretary of state had had disagreements. The president said he and Pompeo have a “similar thought process,” praising Pompeo for his “tremendous energy, tremendous intellect.”

“We’re always on the same wave length,” he said. “The relationship has always been very good. That’s what I need as secretary of state.”