FORT MEADE, Md. — Adrian Lamo, the former computer hacker who reported Pfc. Bradley Manning to military authorities in May 2010 after Private Manning confided that he had provided vast archives of secret government documents to WikiLeaks, testified at the soldier’s court-martial on Tuesday that he saw parallels between his own youthful hacking offenses and those of the young Army intelligence analyst.

Mr. Lamo, who testified for about half an hour, has been a polarizing figure in the WikiLeaks case. He is despised by many of Private Manning’s supporters for betraying the trust of a person they see as an important whistle-blower; Mr. Lamo has maintained that turning Private Manning in was the socially responsible thing to do because his wholesale leaking recklessly endangered others.

Mr. Lamo, who wore black clothing and a light beard, recounted how Private Manning sent him an encrypted e-mail from his personal Google e-mail account, and later contacted him via an online chat service around May 20, 2010. The two later connected on Facebook as well, but did not meet in person.

Mr. Lamo said he first contacted a government official the day after the first online conversation, while continuing to chat online with Private Manning over the next week — sometimes from his home in California, and sometimes from two nearby Starbucks where there was Internet access. The last chat, he said, was around May 26; soon after, Private Manning was arrested.