Republican Trump is in a tense showdown with congressional Democrats over federal funding ahead of a fiscal deadline of midnight on Sept 30, which would trigger a fresh political crisis in Washington.
The memo by the Office of Management and Budget indicated that President Donald Trump's administration would go beyond the usual practice of temporary furloughs during previous shutdowns.
Both judges separately found legal problems with the way the mass terminations were carried out and ordered the employees at least temporarily brought back on the job.
The temporary restraining order came in a lawsuit filed by a coalition of labor unions and organizations as the Republican administration moves to dramatically downsize the federal workforce.
The judge ordered the Office of Personnel Management to inform certain federal agencies that it had no authority to order firings of probationary employees, including at the Department of Defense.
Infosys fired around 400 trainees, with reports of forced same-day eviction and denied overnight stay requests, leaving many scrambling for transport home.