The United States recalled its ambassador to Zambia on Monday after he criticized the government for sending a gay couple to prison and accused officials of stealing millions of dollars of public funds.

Ambassador Daniel Foote had described the treatment of the gay couple as “horrifying” — setting off outrage in Zambia, a conservative Christian country. But analysts said that the main reason for his departure was that he had repeatedly declared that ministry officials had misappropriated millions.

In an unusually combative public statement for a member of the diplomatic corps, Foote had said that the Zambian government “wants foreign diplomats to be compliant, with open pocketbooks and closed mouths.”

Foote’s comments set off recriminations in Zambia, a copper-producing, landlocked country in southern Africa. Zambia’s president, Edgar Lungu, said he did not want Foote in the country, even if Zambia risked losing its annual $500 million in U.S. aid.

“We don’t want such people in our midst. We want him gone,” Lungu told the state-owned television channel ZNBC on Sunday.

He later told Sky News, “If that is how you are going to bring your aid, then I’m afraid the West can leave us alone in our poverty. And we’ll continue scrounging and struggling.”

The State Department said it was dismayed that the Zambian government had declared that Foote’s position as ambassador was “no longer tenable.” The department said that his remarks were “the equivalent of a declaration that the ambassador is persona non grata.”

Foote is a career diplomat who was appointed U.S. ambassador to Zambia by President Donald Trump in November 2017. In his statement, released in early December, Foote had said that the Zambian foreign minister had accused him of interfering in internal affairs for speaking out about the “harsh sentencing of a homosexual couple.”

Despite all the aid Zambia receives, the ambassador wrote, he had found it very difficult to get an audience with the president.

“Both the American taxpayers, and Zambian citizens, deserve a privileged, two-way partnership, not a one-way donation that works out to $200 million per meeting with the head of state,” Foote wrote.

The administration of Lungu, who was first elected in 2015 after his predecessor died in office, has been widely criticized as corrupt. One Zambian analyst recently called it “kleptocratic,” saying grand corruption has become endemic and the economy is faltering.

A recent report by the Environmental Investigation Agency, an international organization that investigates environmental crime and abuse, described the president, his daughter and two ministers as central figures in a “cartel” that traffics mukula rosewood trees. It said that the trees are on the verge of commercial extinction.

Foote had spoken out about corruption in Zambia before.

“His voice is powerful. He had exposed their hypocrisy and corruption,” said the popular musician Fumba Chama, who has repeatedly criticized government corruption in his songs.

Chama said the furor over the ambassador’s comments on gay rights was just a pretext, and the real issue was his bold condemnation of corrupt officials.

“They brought up the LGBT thing because they knew if they brought it to the fore, the public would side with them. Zambia is a very religious country,” Chama said.