WASHINGTON — The Justice Department said Friday night that it had gained access on its own to a locked iPhone used by a Brooklyn drug dealer, the second time in less than a month that it had unlocked such a device after initially insisting it could do so only with Apple’s help.

In a short letter to a federal judge in the Eastern District of New York, prosecutors said that an unidentified person had given the phone’s passcode to investigators. The Brooklyn phone had become the latest battleground in the fight between Apple and the Justice Department over issues of privacy and security.

Last month, in a higher-profile case that set off a national debate, prosecutors dropped their demand that Apple develop software to unlock an iPhone used by one of the attackers in the San Bernardino, Calif., rampage in December. The F.B.I. unlocked that phone after paying an outside party to demonstrate how to do so.

In the Brooklyn case, the drug dealer’s phone was running an older operating system that lacks the encryption features of the San Bernardino phone, so unlocking that device would involve much less technical sophistication even without the passcode.