The past decade has witnessed a growing interest in electric vehicles (EVs) from both academia and industry. Such an interest is driven by the environmental and economic advantages brought by EVs. A recent study has revealed that the annual operation cost of an EV in the U.S. is $485 on average, while it is $1,117 for a gasoline-fueled vehicle, which represents 57% reduction in annual expenses. Furthermore, recent studies have demonstrated that EVs can significantly reduce the carbon dioxide emissions as they reduce the dependence on fossil fuel. Due to the aforementioned advantages, a recent report has shown that the number of EVs on the U.S. roads has increased over the past decade from a couple of thousands in 2011 to $1.2 million vehicles in 2019. A similar trend has been also observed worldwide. To accommodate the charging demands of such EVs, charging facilities have been deployed across the parking lots at residential and commercial units and at work places. Furthermore, fast charging stations have been allocated to serve EVs traveling on the roads. To cope up with the exponential increase in the number of EVs, additional measures have been adopted including temporal and spatial coordination of EV charging and discharging requests. In order to carry out the aforementioned planning and operational goals, advanced stochastic models and optimization techniques must be employed in order to: (a) model the stochastic nature of arrival and departure of EV charging requests, (b) model regular loads and generation units in the power grid to efficiently balance the total supply and demand, (c) allocate EV charging stations in the most economic manner while accounting for spatial and temporal increase of EV charging demands, and (c) coordinate the charging requests of parked and mobile EVs in the most satisfactory manner. This tutorial will equip the researchers with theoretical background of stochastic models and optimization techniques needed for efficient integration of EVs in smart grids. These tools include: Markov processes, queue models, stochastic geometry, mixed-integer programming, heuristic optimization, and game theory. The application of these tools to design planning and operation algorithms for EV integration in smart grids will be covered. This include optimal static and dynamic allocation of charging stations, optimal design of number of chargers and waiting space in charging station, and temporal and spatial coordination of charging requests from parked and mobile EVs in grid-to-vehicle (G2V), vehicle-to-grid (V2G), and vehicle-to-vehicle (V2V) scenarios. Furthermore, the tutorial will present datasets and simulators available for researchers and discuss their application scenarios.