The new firm, which now has about 300 employees working in offices around the world, is moving to position itself as a leader in digital security. The firm hopes that in hiring Mr. Berglas, who most recently was the assistant special agent in charge of cyber investigations for the New York office of the F.B.I., will strengthen its reputation in online security investigations and help it recruit other investigators.

Mr. Berglas’s departure from the F.B.I. is not likely to affect the investigation into the breach of JPMorgan, which resulted in hackers gaining access to email addresses and phone numbers for 83 million households and small businesses. For some time now, federal authorities have been confident that they will be able to identify and file criminal charges against some of the hackers, possible as soon as next month, said two people briefed on the matter but not authorized to speak publicly.

The F.B.I. has already been concerned about losing top talent to the private sector, which can pay big salaries to hire investigators at a time of rising worry over hackers and data breaches.

In 2013, Mr. Berglas caused a bit of a stir in the hacker world when he told The Huffington Post that the F.B.I. had effectively neutralized Anonymous, a confederation of so-called hacktivists, as a source of major online attacks. Mr. Berglas said a series of arrests the F.B.I. had made of some Anonymous members had proved to be an effective deterrent.

More recently, Mr. Berglas has taken part in a campaign by the F.B.I. to encourage United States companies to be more proactive in reporting data breaches and intrusions by hackers to federal authorities. In his new job at K2, Mr. Berglas will find himself working on digital security from the other side, advising companies that either have been breached or are trying to avoid it.