Republican Gov. Sam Brownback’s time in Kansas politics will draw quickly to a close after the U.S. Senate voted narrowly Wednesday in favor of his confirmation for a federal job as ambassador of international religious freedom.

Senators deadlocked 49-49, and Vice President Mike Pence cast a tie-breaking vote to make Brownback ambassador-at-large in the U.S. Department of State.

It wasn’t immediately clear when Brownback would resign and hand the job of governor to Lt. Gov. Jeff Colyer, who is running for the Republican nomination in the 2018 gubernatorial campaign.

Brownback waited nearly six months for the Senate to confirm his hotly contested nomination. He used social media to thank President Donald Trump, Pence and senators who supported his lurching effort to join the Trump administration.

“I’m looking forward to starting my new position as ambassador and working hard for the American people and religious freedom around the world,” Brownback said.

U.S. Sen. Pat Roberts, a Kansas Republican, praised Brownback’s commitment to “fight for those of all faiths.”

He said he was glad Brownback would now have the opportunity to lead the nation’s efforts to promote religious tolerance and to fight religious persecution and discrimination.

Fellow Kansas Republican Sen. Jerry Moran said it was a “privilege” to support Brownback’s nomination. He said Brownback had “demonstrated his commitment to promoting the freedom of all to practice the religion of their choice.”

Brownback, a Catholic who regularly attends noon church services, was emotional the day after his nomination in July. He said religious persecution was worsening worldwide, a stark contrast to freedom he had to take Communion earlier that day.

“I took Communion and people face death around the world for a simple act,” Brownback said.

Brownback will head a federal office charged with promoting religious freedom as a feature of U.S. foreign policy. He would lead an office that monitors threats to religious liberty around the world but doesn’t play a role domestically on the issue.

The position was last held by Rabbi David Saperstein, former director of the Union for Reform Judaism’s Religious Action Center. As a U.S. senator, Brownback helped shepherd the bill that created his new position.

“Religious freedom is the first freedom,” Brownback tweeted after his nomination. “The choice of what you do with your own soul. I am honored to serve such an important cause.”

Brownback’s nomination was a source of celebration among religious conservatives, but he has faced criticism over his record on LGBTQ issues, abortion and the rights of Muslims. As governor, Brownback rescinded an executive order issued by his predecessor, Democratic Gov. Kathleen Sebelius, that extended protection from discrimination to state employees.

Trump nominated Brownback to the post in July after a lengthy legislative session led to repeal of the governor’s signature income tax cut policy. At his October confirmation hearing, Brownback took heated questions from members of the Senate Foreign Relations Committee over his record of social conservatism.

During the hearing, Sen. Tim Kaine, a Virginia Democrat and former vice presidential nominee, contended religious freedom could be used as an excuse for discrimination or persecution.

Brownback’s nomination made it out of committee on a thin party-line vote, but his confirmation process soon stalled in the U.S. Senate. The Senate committee process had to be repeated because he wasn’t confirmed by Dec. 31.

Months after his nomination, Brownback began handing off key gubernatorial responsibilities to Colyer, who appointed a new secretary for the Department for Children and Families and was expected to develop the governor’s annual budget. Still in Kansas, Brownback delivered the budget and the annual State of the State address in early January.

Since then, Brownback has faced opposition on several major projects, including reauthorization of his administration’s privatized Medicaid system.

When Brownback recommended a budget adding $600 million to K-12 public schools, legislators from his party balked, and state Senate Majority Leader Jim Denning, an Overland Park Republican, urged Brownback to depart for his federal job.

Washburn University political science professor Bob Beatty called Brownback a “double” lame duck, or “lame goose,” because of opposition to his policy proposals.

U.S. Senate Majority Leader Mitch McConnell moved to fast-track Brownback’s confirmation this week. Senators agreed to cloture, which limits debate on an issue to 30 hours, earlier Wednesday, also on a 49-49 tie broken by Pence.

“I’m glad to have the vice president in my corner,” Brownback said.

He called his new post a “critical job.”

Brownback’s confirmation was quickly criticized by advocacy groups and the Kansas Democratic Party.

Democratic Party chairman John Gibson said in a statement that Brownback’s policies would remain in Kansas.

“Lt. Gov. Jeff Colyer, whose major action in office was throwing the state’s Medicaid program into privatized disrepair, has been the most aggressive defender of the failed Brownback agenda,” Gibson said. “Meanwhile, Secretary of State Kris Kobach has made the basis of his campaign a return to Brownback-era tax policy. To truly move beyond Brownback, we need to elect a Democrat as governor this November.”

The Democratic Governors Association said the same in a statement.

“Today, Sam Brownback is finally leaving Kansas, but the Brownback nightmare is far from over,” the group said.

Tom Witt, executive director of Equality Kansas, said his LGBTQ advocacy group was “disappointed” by the confirmation vote.

“We hope as he represents our nation on the world stage he remembers he now represents all Americans, not merely a narrow anti-LGBT ideology,” Witt said.