She had entered the courtroom with several other women shortly before addressing the judge. Speaking for only a few moments, she said the attack was on her mind constantly.

“He used his weapon and basically destructed my life with the choice he made that day,” she said.

Mr. Pena also spoke briefly and haltingly. He apologized for the “pain and anguish” he had caused the victim, her friends and family, as well as his own friends and family, who were also represented in the courtroom. He said he wished he could go back to that day “and grab myself by the shoulder,” as his voice trailed off.

“I have no explanation for what happened that day,” he added.

Justice Carruthers barely let Mr. Pena finish his last sentence before levying a 25-years-to-life term on each of the three predatory sexual assault counts, to be served consecutively. The judge praised the young woman’s bravery and composure during the attack and throughout the prosecution.

Mr. Pena was off duty when he grabbed the woman just after 6 a.m. on Aug. 19 in the Inwood section of Manhattan. She was waiting outside for a ride to her first day in a new job teaching second grade when Mr. Pena accosted her at gunpoint; he led her to a courtyard, where he repeatedly sexually assaulted her, threatening to shoot her in the face if she made any noise or opened her eyes.

Justice Carruthers dismissed a claim by Mr. Pena’s lawyer, Ephraim Savitt, that Mr. Pena had been drunk and not entirely aware of his actions.