Security incidents such as denial of service (DoS), scanning, malware code injection, viruses, worms, and password cracking are becoming common in a cloud environment that affects companies and may produce a financial loss if not detected in time. Such problems are handled by presenting an intrusion detection system (IDS) into the cloud. The existing cloud IDSs affect low detection accuracy, high false detection rate, and execution time. To overcome this problem, in this article, a gravitational search algorithm-based fuzzy inference system (GSA-FIS) is developed as intrusion detection. In this approach, fuzzy parameters are optimized using GSA. The proposed consist of two modules namely; possibilistic fuzzy c-means (PFCM) based clustering, training based on the GSA-FIS, and testing process. Initially, the incoming data is pre-processed and clustered with the help of PFCM. PFCM detects the noise of fuzzy c-means clustering (FCM), then conquers the coincident cluster problem of possibilistic fuzzy c-means (PCM) and eradicate the row sum constraints of fuzzy possibilistic c-means clustering (FPCM). After the clustering process, the clustered data is given to the optimized fuzzy inference system (OFIS). Here, normal and abnormal data are identified by the fuzzy score, while the training is done by the GSA through optimizing the entire fuzzy system. In this approach, four types of abnormal data are detected namely- probe, remote to local (R2L), user to root (U2R), and DoS. Simulation results show that the performance of the proposed GSA-FIS based IDS outperforms that of the different schemes in terms of precision, recall and F-measure.