The President's latest reach for untamed executive power led him into yet another surreal head to head with the courts as Independence Day approached.

He forged ahead Wednesday even though the Supreme Court had previously frozen his efforts on the matter and the Justice Department, apparently conceding they had a weak case, had given up. And he tweeted early on Independence Day that people from the departments of Commerce and Justice were working over the holiday to resolve the issue

Going into the hearing on Tuesday where the Justice Department said the administration would not print the census with the question, there was "consensus" including from the White House on the position the DOJ took, according to a US government official. But, a source familiar says after the Tuesday hearing the President's position on the census shifted, something top DOJ officials including Attorney General William Barr became aware of before the President's tweet.

Trump's stance led to an extraordinary exchange between a Maryland judge and a government lawyer hauled back from vacation who was clearly as confused over the drama as anyone else.

"I don't know how many federal judges have Twitter accounts, but I happen to be one of them and I follow the President," said Judge George Hazel on a conference call with case lawyers.

"And so I saw a tweet that directly contradicted the position (the government) shared with me yesterday."

The unfortunate Justice Department lawyer Joshua Gardner was forced to admit he had no clue either and so became the latest government official to be professionally undermined by the President's whims.

"The tweet this morning was the first I had heard of the President's position on this issue," Gardner said.

"Obviously, as you can imagine, I am doing my absolute best to figure out what's going on," Gardner said, according to a court transcript of the conference call.

The President acted following a backlash on pro-Trump media about a cause dear to the conservative movement's heart after the Justice Department appeared to lose faith.

Conservative radio host Hugh Hewitt tweeted that if the case was really over , "it would be one of the biggest legal defeats of the Trump presidency."

Presented with a choice between the reality established by the courts or a potential blow to his standing in his political base, Trump made a familiar move.

"The News Reports about the Department of Commerce dropping its quest to put the Citizenship Question on the Census is incorrect or, to state it differently, FAKE!" Trump tweeted Wednesday.

"We are absolutely moving forward, as we must, because of the importance of the answer to this question."

Doubts raised over the functioning of government

It would not be the first time that Trump has bowed to the conservative media machine. He backed out of a deal with Democrats on immigration amid conservative fury over the compromise.

But the head-spinning developments on Wednesday pose deeper questions than Trump's relationship with his conservative base.

They stir fresh uncertainty about his respect for the rule of law and the rulings of the courts -- including the Supreme Court. Given the flurry of challenges to the President's refusal to submit to constitutionally authorized congressional oversight, this is an issue that will shortly become even more acute.

The Supreme Court last week upheld a lower court ruling that the government had violated legal procedure and the Constitution by adding a citizenship question to the census.

Trump has said that it would be "ridiculous" not to include such a question. But government lawyers may struggle to find other arguments to alter the Supreme Court majority on the issue.

"Their position was hopeless. This tweet doesn't make their position any less hopeless. ... It's just nuts," said CNN Chief Legal Analyst Jeffrey Toobin.

It was not clear whether Trump meant officials to press ahead with a census that includes the citizenship question -- or whether he wants to launch a new longshot legal challenge to make it feasible.

It's also possible he knows that the effort is doomed but wants to show his supporters he's putting up a tough fight.

Wednesday's developments were yet another example of the chaotic nature of an administration that often lurches from day to day based on the President's erratic decisions and policy reversals. It's a tendency that has recently been in evidence especially on foreign and trade policy.

It's a state of affairs that suggests a worrying lack of continuity when one arm of the government has no idea what the other is doing from moment to moment.

It would not be a surprise if Trump reacts to Hazel's intervention with a fresh attacks on the judiciary itself. He has frequent responded to judges who block his policies by alleging a political conspiracy. Things got so heated after a district court ruling against his asylum policies that Chief Justice John Roberts issued an unprecedented statement that implicitly rebuked the President.

"We do not have Obama judges or Trump judges, Bush judges or Clinton judges," Roberts said. Hazel was nominated by President Barack Obama.

Checks on presidential power

The way in which courts have frustrated Trump reflects the fact that the judiciary has been one of the most effective checks on the President's power.

Trump can walk into North Korea, as he did on Sunday, can commandeer Washington's July Fourth celebrations, brand the media the "enemies of the people" and undermine truth.

But the power of the President of the United States can be held in check by a humble district court judge.

That doesn't make the mercurial President any easier to work for, as Gardner found out on Wednesday, as he tried to salvage his reputation.

"I've been with the United States Department of Justice for 16 years, through multiple administrations, and I've always endeavored to be as candid as possible with the court," he told the judge.

Other top government officials, like former Secretary of State Rex Tillerson -- who Trump told not to waste his time talking to North Koreans in a 2017 tweet -- might pity Gardner.

More recently, the President gave his trade chief Robert Lighthizer a dressing down in front of a Chinese delegation when he ordered him to stop using the phrase "memorandum of understanding." MOUs are now non grata in the White House.

While Hazel appeared sympathetic with Gardner's plight, he was clearly frustrated.

"If you were Facebook and an attorney for Facebook told me one thing and then I read a press release from Mark Zuckerberg telling me something else, I would be demanding that Mark Zuckerberg appear in court with you the next time because I would be saying 'I don't think you speak for your client." Hazel said.

A US government official told CNN on Thursday that the census printing without a citizenship question is still going forward.

The judge gave the Justice Department until 2 p.m. ET Friday to either confirm the government would not put a citizenship question on the census or to say how it will pursue the case.

But even a federal judge can only do so much.

"Maybe I'm wrong about this, that the parties are not suggesting I can enjoin the President of the United States from tweeting things?" he said.

This story has been updated with additional developments Thursday.