One of the major obstacles along the way of electric vehicles' (EVs') wider global adoption is their limited driving range. Extreme cold or hot environments can further impact the EV's range as a significant amount of energy is needed for cabin and battery temperature regulation while the battery's power and energy capacity are also impeded. To overcome this issue, we present an optimal control strategy based on nonlinear model predictive control (NMPC) for integrated thermal management (ITM) of the battery and cabin of EVs, where the proposed NMPC simultaneously optimizes the EV range and cabin comfort in real time. Firstly, the components of the designed ITM system are introduced and control-oriented modeling is done. Secondly, to demonstrate and validate the benefits of the proposed ITM, an optimal control problem is defined and dynamic programming (DP) is employed to find the global optimal solution. Thirdly, for practical implementation, NMPC-based control strategy is developed, where the cost function design and weights calibration are done in comparison with DP global optimal solution. Weight-tuning results show that our NMPC-based approach can achieve close driving range maximization as compared to the DP benchmark while ensuring cabin comfort. The developed NMPC-based ITM strategy is further illustrated by comparing its performance to two additional benchmark strategies, i.e., rule-based control and cabin heating only. Finally, our simulation results also identify several important factors that impact the benefits of the proposed NMPC-based ITM, which are used to summarize the operating conditions under which the proposed ITM is critically needed.