Mr. Flemmi, known as the Rifleman and serving life in prison for murder, was the prosecution’s star witness, recounting how Mr. Bulger, his former friend and partner in crime, had committed at least half a dozen murders himself. But during a brutal cross-examination on Tuesday, Mr. Bulger’s defense lawyer turned the tables and put the spotlight on Mr. Flemmi, seeking to strip him of any value he may have had as a witness.

He tripped up Mr. Flemmi on various details of their murderous ventures. The witness became confused about whether Mr. Bulger had used his hands or a rope when he supposedly choked Mr. Flemmi’s girlfriend’s daughter, Deborah Hussey, to death. He was similarly uncertain whether Mr. Bulger had strangled another girlfriend, Debra Davis, upstairs or downstairs. He said he was in a state of anxiety in both cases and could not remember exactly what happened.

And most vividly, the defense lawyer, Hank Brennan, portrayed Mr. Flemmi as a man who had sex with a young woman, Ms. Hussey, while he was living with her mother, Marion Hussey. Books about Mr. Bulger have said that Mr. Flemmi sexually molested Deborah from her early teens onward, but in court, Mr. Flemmi said she was 17 (he was 39) when they began a relationship that he said was consensual.

Clearly feeling that he was the one on trial, Mr. Flemmi occasionally tried to drag Mr. Bulger back into the picture and hurled some accusations of his own. At one point, when Mr. Brennan accused him of being a pedophile, Mr. Flemmi blurted out that Mr. Bulger “had a young girl, 16 years old,” whom he had taken to Mexico — “that’s a violation of the Mann Act,” which prohibits interstate transport of women for immoral purposes.

“If you want to talk about pedophilia, look at that man right there at that table,” Mr. Flemmi declared, indicating Mr. Bulger. Mr. Bulger, who has hissed obscenities at other witnesses, including Mr. Flemmi last week, kept his mouth shut and his head down on Tuesday as he scribbled on a yellow legal pad.

It was one of the most riveting days of testimony in the trial. Mr. Bulger faces a sweeping 32-count indictment on charges of racketeering and other crimes and is implicated in 19 murders during what prosecutors have described as his reign of terror in South Boston in the 1970s and ’80s.

But Mr. Bulger, 83, was the forgotten man on Tuesday as Mr. Brennan unloaded a barrage of provocative questions and statements at Mr. Flemmi in an attempt to destroy his credibility.

“When did you become attracted to your daughter?” he asked.

“She was my stepdaughter, please,” Mr. Flemmi responded.

“Oh,” said Mr. Brennan, “since she was not your blood, so to speak, you thought it would be O.K. to be engaged in a sexual relationship with her?”

Mr. Flemmi said the sex began when Deborah had become a drug addict and “a different person” from the one he had known.

Mr. Flemmi, 79, said he kept trying to send Ms. Hussey away on trips and vacations, but she kept coming back, prompting Mr. Brennan to observe, “You talk about her like she’s a stray dog.”

Mr. Flemmi, who was wearing his prison khakis and a windbreaker, was annoyed, argumentative and feisty in his responses. When Mr. Brennan accused him of having lied to Ms. Davis by not telling her that “you were going to kill her,” Mr. Flemmi stopped him. “Is that a sensible question?” he asked.

Judge Casper told him several times not to ask questions or provide commentary on the questions, but Mr. Flemmi ran roughshod over her instructions, only to apologize afterward.

Mr. Flemmi repeatedly cast himself as a bystander, someone simply following orders. He said he would not have participated in the murders of Ms. Hussey and Ms. Davis if Mr. Bulger had only given the word that they did not need to die. But they did, Mr. Flemmi said, because Mr. Bulger decided they knew too much about their underworld dealings.

“You said when you agreed to kill your stepdaughter, you said you did it reluctantly,” Mr. Brennan said.

“I agreed because I was coerced into it,” Mr. Flemmi answered. After a long pause, he added, “And Mr. Brennan, I didn’t kill her.”

Mr. Flemmi did recall that he had taken her shopping just before her murder.

“You thought the last moments of her life would be best spent shopping with you?” Mr. Brennan asked.

Mr. Brennan suggested it was particularly deceptive of Mr. Flemmi to have killed Ms. Davis and then pretend to her family that he was trying to help find her.

Mr. Flemmi said matter of factly that that deception was simply part of his attempt to cover up the crime.

“When you commit a murder, you don’t tell people about it, you try to cover it up,” Mr. Flemmi informed Mr. Brennan. “You should know that. You’re an attorney.”

A version of this article appears in print on July 24, 2013, on Page A16 of the New York edition with the headline: Bulger Lawyer Tries To Weaken Credibility Of Prosecution Witness. Order Reprints|Today's Paper|Subscribe