The FBI has "copied and removed" hundreds of backdoors from Microsoft Exchange servers in the United States, the US Department of Justice reports on its website.
Several months ago, thousands of these email servers were attacked by hackers.
This affected tens of thousands of organizations worldwide, including the US government.
After the attacks, there would have been loopholes in systems that hackers could use to re-enter.
Many system administrators managed to remove them themselves, but hundreds remained active.
The FBI used the backdoors to its advantage and with a technical solution was able to remove only those entries from the servers.
For this hack, the FBI got permission from a Houston court.
It is the first time that the FBI has cleaned up private networks after a cyber attack.
The Ministry of Justice calls the operation a success.
At the beginning of this year, hackers exploited vulnerabilities in Microsoft's Exchange servers to gain access to corporate and government computer systems.
Microsoft found evidence in March that Hafnium, a group of Chinese hackers working on behalf of the state, was carrying out attacks through the affected servers.
Microsoft closed several vulnerabilities, but that did not close back doors that had already been placed in the systems.
According to the Ministry of Justice, this left a number of servers vulnerable, because the back doors were difficult to find and remove.
The danger in Exchange servers does not seem to be over yet.
Microsoft warned Tuesday about two dangerous vulnerabilities in the servers, for which an update has since been released.
See also: Twelve hundred Dutch servers infected after security hole Microsoft