Elon Musk is leaving his government role as a top adviser to President Donald Trump after spearheading efforts to reduce and overhaul the federal bureaucracy.

His departure, announced Wednesday evening, marks the end of a turbulent chapter that included thousands of layoffs, the evisceration of government agencies and reams of litigation. Despite the upheaval, the billionaire entrepreneur struggled in the unfamiliar environment of Washington, and he accomplished far less than he hoped.

He dramatically reduced his target for cutting spending — from $2 trillion to $1 trillion to $150 billion — and increasingly expressed frustration about resistance to his goals. Sometimes he clashed with other top members of Trump’s administration, who chafed at the newcomer’s efforts to reshape their departments, and he faced fierce political blowback for his efforts.