Two men were sentenced to lengthy prison terms for plotting to carry out a killing in Oakland, only to have their plans thwarted when police intercepted them and fatally shot two of their associates.

Wynn Brewer, 33, and Patrick Shields, 31, were found guilty in October by an Alameda County jury of conspiracy to commit murder. Brewer was also convicted of illegal gun possession.

At a Friday hearing in Oakland, Judge Larry Goodman denied their motions for a new trial and sentenced Brewer to 28 years to life in prison and Shields to 25 years to life in prison.

A third defendant, Cyrico Robinson, 28, was found not guilty. A fourth defendant, 34-year-old Willie Pope, entered an earlier plea to assault with a firearm and was sentenced to at least eight years in prison.

Brewer, Shields and Pope were part of a killing plot that included John Sloan, 23, and Antoine Jackson, 30, the two men who were fatally shot by police on May 18, 2011, authorities said.

On that day, police investigators learned through a wiretap on Shields’ cell phone that he and others were planning to kill an Oakland man with whom they were feuding.

Gunmen tried to kill the Oakland man on May 17, 2011, but succeeded only in wounding others, according to an affidavit by Oakland police Officer Anthony Tedesco.

The next day, Tedesco said, Shields learned that the killing target was at Robinson’s home in Oakland, and sent Brewer, Sloan and Jackson to gun him down.

But Capt. Ersie Joyner and Officer Cesar Garcia found and cornered the gunmen in a car on Curran Avenue, commanding them to surrender, Tedesco said.

Brewer ran off with a gun in his hand and was arrested later, Tedesco said, while Sloan also ran and was shot by Joyner when he raised his gun toward the officers.

Jackson, the driver, was shot by Garcia — who has since medically retired — when he reached toward the car’s center console, because officers believed he was “attempting to arm himself,” Tedesco wrote. No gun was found in the car.

Prosecutors cleared Joyner and Garcia. A civil suit filed in U.S. District Court in San Francisco by the families of the dead men is pending.

John Burris, an attorney for the families, has said the men were trying to get away, not shoot the officers.

Henry K. Lee is a San Francisco Chronicle staff writer. E-mail: hlee@sfchronicle.com Twitter: @henryklee