A Brooklyn man's revenge plot against a city garbage collector was foiled two years ago when he accidentally shot and killed his accomplice and friend, the alleged killer's intended victim said in court Monday.

"It was clear in my mind that they were going to try to kill me that night," said Oboi Omari James, who identified his would-be-killer in court. "I was shot right in my back."

James identified Cedric Williams as the man who shot him and the murder victim, Jovani Vincent, as Williams' accomplice in the attack. James said that the two men had reignited a longtime feud with him. In Williams' trial, prosecutors are trying to prove Williams killed Vincent in a botched murder attempt. He faces murder charges for the killing of Vincent and attempted murder charges for the shooting of James, and up to 25 years in prison if convicted.

James was at a party in July 2010 when he says he saw the two old acquaintances from his Bushwick block. When Vincent and Williams approached him, James said he was afraid for his life.

"Jovani [Vincent] struck me and we began fighting," said James, who has a criminal record for selling drugs to an undercover officer. Vincent appeared to be winning before the scuffle turned deadly. "He seemed to have the power of Superman that night."

Thinking Williams would also assault him, James swung at him, too, he said. That's when Williams pulled out a gun. After Vincent knocked him down, Williams shot James in the back.

"I began to take off running … when I was running, I heard other shots rang out," James said.

At some point during the dustup, Williams accidentally shot Vincent.

Both Williams and Vincent were attempting to permanently settle separate gripes with James, prosecutors said. In 1996, Vincent was arrested for murdering someone in a fight. When he was convicted of manslaughter, Vincent blamed James, thinking that James had told police that Vincent had committed the murder. Thirteen years later, "bad blood" also developed between James and Williams when James sideswiped his aunt's car, according to prosecutors.

Tensions simmered until 2010, they said, when James saw Vincent and Williams drive up to the party.

"I immediately began looking for a refuge," James said. "I knew I was in danger."

But after being shot and fleeing for his life, James didn't see his attackers again until he was taken to Brookdale Hospital by emergency services later that night.

"Jovani Vincent is wheeled in right next to me," James said. "It appears he has been killed."

In court Williams appeared calm in a lavender shirt, leafing through papers and speaking softly with his attorney, but he was far from composed in the hospital that night, James said.

"I seen him right next to me," he said, "standing with Jovani, weeping."