A plea bargain is a legal agreement whereby one agrees to accept a sentence in order to gain a concession from a judge or other authority figure. In most cases, the concession is a reduced charge or lessened sentence, or the agreed refusal to impose certain sentences.
Richard Bashir turned himself in for having illegal genetic engineering conducted on his son "Jules" and agreed to serve time in prison in exchange for Julian's being allowed to remain in Starfleet. (DS9: "Doctor Bashir, I Presume")
Commander Benjamin Sisko first arrived on Deep Space 9. Believing it was important to the station's success for Quark to continue to maintain the bar, but knowing the Ferengi did not want to stay aboard, Sisko used the fact that Nog was in custody to negotiate a deal – namely, that Quark stay if Nog was released. (DS9: "Emissary")