Washington(CNN) Five federal courts dealt blows to President Donald Trump on Friday just as the limits of his legal strategy to block an impeachment inquiry became clear.

It amounted to a challenging end of a challenging week for Trump, who remains consumed by an impeachment crisis that is clouding his presidency.

Within moments of each other, a career diplomat began painting a damning portrait of the President's foreign policy to lawmakers just as Trump lost his appeal in a federal appeals court to stop a House subpoena of his tax documents, which he's guarded fiercely since refusing to make them public as a candidate.

Then, in rapid succession, judges in New York, Texas, Washington state and California sided against Trump administration initiatives meant to limit immigrants from entering the country -- both through a physical barrier and by raising the requirements on migrants seeking legal status.

Friday night, the man in charge of executing much of Trump's immigration agenda, acting Homeland Security Secretary Kevin McAleenan, submitted his resignation to the President as the legal setbacks mounted. Long in the works, and by all accounts unrelated to the court decisions or the impeachment crisis, the move nonetheless fueled a sense of an administration in flux. McAleenan was the fourth person to serve in that post since the Trump presidency began.

All of the court cases will be appealed. But the rulings added to the sense of Trump's worsening legal fortunes, and Democratic investigations into his finances and foreign activity seemed to gain steam.

A silver lining came in the afternoon, when Trump announced a "phase one" trade agreement with China that he hopes will signal the beginning of the end of a withering trade war. News of the emerging deal sent stocks soaring, even as the President acknowledged it still requires "papering."

The President remained defiant, telling reporters as he departed the White House for his second rally in two days that he would prevail in the end.

"We'll win," he said. "You know how many cases I've lost and then we win?"

But even as he was speaking, the setbacks were piling up.

A disgruntled deposition

The trouble began in the morning, when Trump's ousted ambassador to Ukraine, Marie Yovanovitch, strode into a deposition on Capitol Hill behind a pair of dark glasses.

Three days earlier, the White House had issued a letter declaring the administration would refuse to comply with Democrats' requests as they speed ahead in their impeachment efforts, saying the proceedings were "illegitimate." Democrats said the White House tried to prevent Yovanovitch's testimony on Thursday evening, so they were forced to issue a subpoena.

In talking points distributed to allies, the White House said that "we are not concerned with any information Yovanovitch might share, because the President did nothing wrong."

But in her prepared testimony, the career diplomat was scathing in her assessment of how Trump conducts foreign policy and of the actions of some of his confidants.

"Although I understand that I served at the pleasure of the President, I was nevertheless incredulous that the US government chose to remove an ambassador based, as best as I can tell, on unfounded and false claims by people with clearly questionable motives," she said in a 10-page statement obtained by The New York Times and The Washington Post.

Yovanovitch's appearance on Capitol Hill illustrates the limits of the legal strategy laid out by Trump's lawyers earlier this week. While the administration has worked to bar officials from appearing before lawmakers, they do not seem able to prevent those officials from complying with subpoenas compelling them to appear.

Already a number of administration officials have signaled they are willing to break with Trump's dictate to not cooperate in the investigation. After his voluntary appearance was derailed by the State Department this week, US Ambassador to the European Union Gordon Sondland plans to appear next Thursday after being subpoenaed by congressional investigators.

Democrats have also scheduled depositions next week with Deputy Assistant Secretary of State George Kent and State Department counselor Ulrich Brechbuhl. Fiona Hill, the White House's top Russia adviser, who left the administration in August, has been scheduled to appear for a deposition on Monday.

It's not clear if all intend to appear, and one Trump congressional ally downplayed the testimony of administration officials as defiance of the White House, saying they're doing so only under subpoena.

But the pattern of administration officials choosing Congress over the White House remains a remarkable choice for a President who routinely demands loyalty from those who work for him.

'No authority'

There was another signal Friday that the White House strategy of refusing to cooperate could face an uphill battle. In the tax document ruling, the federal appeals panel wrote it has "no authority" to require the House to take a full vote in support of a subpoena to investigate the President, citing the Constitution.

It's the first major case at the appeals court level in the standoff between the House and Trump. The President so far has lost all of his challenges to stop House subpoenas that have been decided at the trial court level.

Trump may appeal to the Supreme Court to stop the release of his tax records, but courts, including the Supreme Court, previously have refused to curtail Congress' subpoena power.

That ruling preceded a day of setbacks on Trump's immigration agenda, designed around efforts to limit migrants from entering the country.

A federal judge in Texas ruled the President's national emergency declaration to build a border wall unlawful and appeared poised to block the use of those funds. At issue is $3.6 billion in military construction funds that has been diverted to build the wall, which remains one of Trump's chief campaign promises.

Meanwhile, judges in New York, California and Washington state blocked implementation of a Trump administration rule that would make it more difficult for immigrants who rely on public assistance to obtain legal status, just days before the regulation was set to take effect.

Under the proposed rule, many green card and visa applicants could be turned down if they have low incomes or limited education because they'd be deemed more likely to need government assistance in the future, including most forms of Medicaid, food stamps and housing vouchers.

Trump appeared nonplussed by the immigration setbacks as he departed the White House on Friday afternoon for a rally in Louisiana. He was emerging from a meeting with China's vice premier, where he announced a "phase one" trade deal he said amounted to a "love fest" after months of friction.

"We lost on immigration?" he asked when questioned about the string of rulings. "I haven't heard that. We'll win. We'll turn -- you know how many cases I've lost and then we win?"

Elsewhere, his senior adviser was less sanguine.

"It impedes democracy," Stephen Miller, who leads Trump's efforts on immigration, told reporters in the White House driveway.