Opioids are powerful analgesics; however, their significant systemic adverse effects and the need for frequent administration restrict their use. Nalbuphine (NA) is a κ-agonist narcotic with limited adverse effects, but needs to be frequently administrated due to its short elimination half-life. Whereas sebacoyl dinalbuphine ester (SDE) is a NA prodrug, which can effectively prolong the analgesic effect, but lacks immediate pain relief. Therefore, in this study, a rapid and sustained local delivery formulation to introduce NA and SDE directly into surgical sites was developed. An amphiphilic nanostructured lipid carrier (NLC) poloxamer 407 (P407) gel (NLC-Gel) was developed to permit concurrent delivery of hydrophobic SDE from the NLC core and hydrophilic NA from P407, offering a dual rapid and prolonged analgesic effect. Benefiting from the thermal-sensitive characteristic of P407, the formulation can be injected in liquid phase and instantly transit into gel at wound site. NLC-Gel properties, including particle size, drug release, rheology, and stability, were assessed. In vivo evaluation using a rat spinal surgery model highlighted the effect of the formulation through pain behavior test and hematology analysis. NLC-Gels demonstrated an analgesic effect comparable with that of commercial intramuscular injected SDE formulation (IM SDE), with only 15 % of the drug dosage. The inclusion of supplemental NA in the exterior gel (PA12-Gel + NA) provided rapid drug onset owing to swift NA dispersion, addressing acute pain within hours along with prolonged analgesic effects. Our findings suggest that this amphiphilic formulation significantly enhanced postoperative pain management in terms of safety and efficacy.