Background: A brain tumor is one of the most common and fatal neurological diseases that may require surgery. The correct diagnosis of the location and size of the tumor can be a diagnostic aid program for medical robots during surgery, and it also helps doctors formulate a suitable treatment plan for the patient. Objectives: To develop an algorithm based on support vector machine (SVM) for the detection and classification of tumors into benign and malignant types on MRI images. Methods: In this retrospective study, 160 MRI images were obtained from the KAGGLE website. The studied subjects included two groups: Benign tumors and malignant tumors. At first, preprocessing and noise removal were done by comparing four filters: Butterworth, wavelet, ideal, and median. Finally, the SVM algorithm was used to classify brain tumors into benign and malignant. Results: The performance evaluation of the filters showed that the median and wavelet filters had the best performance in removing noise from MRI images. Then, the discrete wavelet transform (DWT) extracted the required features from MRI images and was used as the input of the SVM algorithm. The accuracy, precision and specificity of the proposed algorithm in diagnosing benign and malignant brain tumors were 95%, 88% and 91%. Conclusions: The findings of recent studies show that this algorithm can be used to improve the accurate diagnosis of brain tumors and their types. Combining morphological features can also be a diagnostic tool to increase accuracy in robotic surgeries.