In the last two decades, Nipah virus (NiV) has become a significant paramyxovirus transmitted by bats, causing severe respiratory illness and encephalitis in humans. Due to the severity of the disease, its potential for human-to-human transmission, zoonotic characteristics , and the absence of approved therapeutic treatments, NiV has been included in the World Health Organization’s Blueprint list of priority pathogens. In this paper, a novel mathematical model is proposed to investigate the dynamics and optimal control of the NiV. The model incorporates two modes of transmission: human-to-human and food-borne. It also considers the impact of coming in contact with an infected corpse as a potential route for virus transmission. The NiV model is initially assessed with constant controls. The analysis identifies three equilibrium states: the NiV-free equilibrium, the infected flying foxes-free equilibrium, and the NiV-endemic equilibrium state. Furthermore, a theoretical analysis is conducted to ascertain the stability of both the Nipah virus-free equilibrium and the Nipah virus endemic equilibrium points of the model. In addition to enhance the biological importance of the study, the model is fitted to the reported cases in Bangladesh during 2001 to 2015 and the model parameters are estimated using standard nonlinear least square technique. A sensitivity analysis of the model-embedded parameters is conducted to derive the optimal time-dependent controls. An optimal control model is formulated using the sensitivity indices, and numerical simulations are employed to determine the most effective strategy for disease eradication. The model is optimized via optimal control theory coupled with well-established Pontryagin’s maximum principle utilized to achieve primary optimality simulation. Finally, simulation results are provided to verify the theoretical results.