A key prosecution witness at a trial in one of the largest arsons in state history recanted on the stand Wednesday, testifying that he lied when he implicated Patrick S. Walsh in the fires that raged through a subdivision under construction in Southern Maryland last year.

The surprise testimony came from Michael E. Gilbert, one of six young men initially charged with setting the fires and the only one against whom charges were later dropped. Gilbert, 21, testified in federal court under an immunity order.

"I was scared," Gilbert said, recalling more than nine hours of questioning by investigators two weeks after the fires at Hunters Brooke in Charles County, about 30 miles south of Washington. "I didn't know what to do."

He said that, in the interview Dec. 20, he implicated his friend Walsh only because investigators were accusing him of lying and he "couldn't take it" any longer. He grew so desperate, he said, that at one point he asked for a gun with the intention of taking his own life.

In the end, Gilbert told the jury, he lied. "To me, the truth wasn't working, so I figured I'd say what they wanted to hear and then I could go home," he testified.

During that interview, Gilbert gave a statement saying that Walsh had tried to recruit him in a plan "to make the Family" -- a group of local young people that Walsh led -- "bigger and more famous," according to a law enforcement affidavit made public at the time.

Gilbert told investigators that the plan "had to do with setting 'something' on fire and . . . would be big," the affidavit said. It said Gilbert quoted Walsh as saying: "You know something's going down, and it will probably be Sunday. I want you to know that this is your last chance. Do you want to be in on it or not?"

Gilbert told investigators that he declined, the affidavit says.

Through her questions, Assistant U.S. Attorney Donna C. Sanger suggested that loyalty to the Family could explain Gilbert's changing story. Gilbert also acknowledged in his testimony that he did not ask for an attorney during the interrogation, which ended in his arrest.

Gilbert's statement to investigators, though contradicted by Wednesday's testimony, was the most direct evidence the jury has heard to date pointing to Walsh's involvement in the fires, which prosecutors say were intended to enhance the credibility of the Family. In his opening statement last week, Walsh's attorney, William B. Purpura, said neither DNA nor fingerprint evidence would tie Walsh to the crime.

Although two other men have pleaded guilty and admitted involvement in the fires, neither has testified. Prosecutors said Wednesday that they do not intend to call one of the men, security guard Aaron L. Speed, because of concerns that defense attorneys could impeach him.

The immunity order prevents Gilbert, testifying under subpoena, from invoking his right against self-incrimination. Under the order, his court testimony cannot be used to prosecute him for past offenses, including the fires or any subsequent false statements to investigators. However, it does not protect him from perjury charges that could arise if prosecutors decided that he lied in court Wednesday.

The Dec. 6 fires damaged or destroyed more than two dozen unoccupied houses under construction at Hunters Brooke, a predominantly black development. They fueled a perception that racial hostility persisted in Charles County.

The trial resumes Thursday.