The court said the agencies violated their own termination rules and the officers' Fifth Amendment due-process rights by denying them chances for reassignment and internal appeal.
Government lawyers had argued the CIA director and DNI could fire employees with or without cause, but the panel said enforcing agency procedures did not strip those chiefs of authority.
The officers were intelligence specialists, not diversity hires, and had been moved into diversity roles during the Biden administration as the agencies pushed to broaden recruitment.
The Trump administration is expected to appeal, and it remains unclear how quickly the officers could be placed into new posts if the ruling stands.