The attack has not previously been reported. Carter said attackers discovered a vulnerability in an older network that hadn't been repaired. An elite Defense Department team identified the break-in and began looking for the culprits, he said.
"After learning valuable information about their tactics, we analyzed their network activity, associated it with Russia, and then quickly kicked them off the network, in a way that minimized their chances of returning," Carter said.
He offered few other details about the incident but said that while it was troubling Russian hackers had gained entry, he said the Pentagon had reacted rapidly.
The government is regularly targeted by hackers, but officials rarely place the blame publicly. Earlier this month CNN reported that the State Department and the White House had also been breached by Russian attackers with ties to its government.
Carter did not say that the group suspected in the Defense Department hack had ties to the Russian government.
The Defense Secretary spoke as part of a visit to build relationships with Silicon Valley and lay out an updated Pentagon strategy for fighting battles over computer networks. The heart of those efforts is a projected 6,000 person force based at Fort Meade and split into 133 teams.
The new strategy reflects the Pentagon's growing willingness to talk about its offensive powers in cyberspace. The majority of the teams will be dedicated to defensive missions, but 27 of them will have a combat role, according to the Pentagon.
"Adversaries should know that our preference for deterrence and our defensive posture don't diminish our willingness to use cyber options if necessary," Carter said.
The new strategy paper lays out possible ways military could use attacks: "If directed, DoD should be able to use cyber operations to disrupt an adversary's command and control networks, military-related critical infrastructure, and weapons capabilities."
Carter also pledged to be more transparent about the department's efforts to build hacking weapons in an effort to stop conflicts spiraling out of control as other nations also build up their cyberwarfare teams.
"Because stability depends on avoiding miscalculation that could lead to escalation, militaries must talk to each other and understand each other’s abilities," Carter said.