Nowadays, the Smart Grid (SG) is becoming smarter thanks to the integration of different information and communication technologies to enhance the reliability and efficiency of the power grid. However, several issues should be met to ensure high SG performance. Among these issues, we cite the problem of electric vehicles (EVs) integration into the SG to avoid electricity intermittence due to the important load that EVs can create. Another issue is the SG communication network security that can be attempted by malicious intruders in order to create damages and make the power grid instable. In this context, we propose at a first level a Bayesian game-theory model that aims to integrate optimally EVs into the SG and maintain the equilibrium between the offer and the demand. At a second level, we propose an Intrusion Detection System (IDS) to protect the SG from attacks that aim to disturb the state estimation. Numerical results prove the efficiency and robustness of our proposed models.