In this paper, a novel approach based on Binary Black Hole Algorithm (BBHA) and Random Forest Ranking (RFR) is proposed for gene selection and classification of microarray data. In this approach, RFR and BBHA are used to perform gene selection to remove irrelevant and redundant genes. Because of its ability in reducing noise, bias and variance errors Bagging with 10-fold cross validation is selected as a classifier. The result of RFR-BBHA-Bagging is compared to seven benchmark classification methods. Experimental results show that our proposed method by selecting the least number of informative genes can increase prediction accuracy of Bagging and outperforms the other classification methods.