This research focused on modeling and optimizing production and outsourcing operations in a supply chain (SC) while considering environmental challenges. The proposed mathematical model was nonlinear, implying outsourcing, and took into account reworking and carbon tax. It was solved using sequential quadratic programming (SQP) to achieve best solutions. Transportation significantly impacts carbon emission, which, herein, was considered the total cost of the SC. The model was tested using data from the automobile part industry, and sensitivity analyses were performed to understand the impacts of individual parameters on the total cost of the supply chain. The results could provide valuable insights for managers seeking to optimize production and outsourcing for a resilient supply chain.