Image copyright Getty Images Image caption The ethics chief resigned in a letter to President Donald Trump

The US government's top ethics watchdog has announced his intention to resign, after repeatedly clashing with President Donald Trump.

Walter Shaub, director of the Office of Government Ethics (OGE), will leave his post on 19 July.

"In working with the current administration, it has become clear to me that we need improvements to the existing ethics programme," he said.

The White House said in a statement that it "appreciates his service".

"The president will be nominating a successor in short order," it added.

Mr Shaub was appointed to a five-year term in 2013, and had six months left.

He will now join the non-profit Campaign Legal Center, which advocates tougher campaign finance laws, as its senior director of ethics.

Writing on Twitter, he said he would be working on "ethics reforms at all levels of government".

The departing ethics chief wrote to the president to explain his decision, before sharing the letter online.

He did not directly criticise Mr Trump, but said it had been a privilege to work with colleagues who protect the principle of placing "loyalty to the Constitution, the laws, and ethical principles above private gain".

Image copyright Twitter/WalterShaub

Mr Shaub's first tensions with the president came before the Republican even took office, over his plan to hand control of his business empire to his sons.

In January, he said the proposal would not remove conflicts of interest, and did not match the "standards" of US presidents over the last 40 years.

"Every president in modern times has taken the strong medicine of divestiture," he said, referring to a process where Mr Trump would sell off his corporate assets and put the profits into a blind trust run by an independent trustee.

The OGE faced similar stresses in certifying Mr Trump's Cabinet nominees, many of whom had considerable financial assets and business interests.

Bailing out of a pointless task: Analysis by Anthony Zurcher, BBC North America reporter

Walter Shaub could see the writing on the wall. The government ethics watchdog's attempts to review possible conflicts of interest among the Trump administration were frequently thwarted. His calls for greater transparency in the White House were disregarded. His recommended reforms to strengthen his office's oversight abilities were shrugged off.

The job of a government ethics watchdog is almost always a thankless one. In the age of Trump, however, it was more than that. It was pointless. The president and his staff are the ones who determine what is and isn't ethical. They're setting their own rules, and they are the only ones holding themselves accountable.

In February, Mr Shaub urged the White House to investigate presidential aide Kellyanne Conway after she urged Fox News viewers to "Go buy Ivanka's stuff" during an interview - breaking rules that stop staffers from endorsing products.

The White House declared that Ms Conway had spoken "without nefarious motive," and should not be disciplined. Mr Shaub responded that by failing to take action, it risked "undermining the ethics programme".

Despite the obvious flashpoints between them, Mr Shaub told the Washington Post he had not been pressured to stand down by the Trump administration.

"It's clear that there isn't more I could accomplish," he said.

Mr Trump will now be able to choose his own ethics director to replace Mr Shaub, subject to confirmation by the Senate.