In this paper, a novel opportunistic spectrum sharing scheme, based on orthogonal frequency division multiplexing with index modulation (OFDM-IM), is proposed for cognitive radio (CR) networks. In the considered OFDM-IM based CR (OFDM-IM-CR) model, the primary transmitter (PT) communicates with the primary receiver with the aid of an amplifiedand-forward (AF) relay by transmitting OFDM-IM signals. Meanwhile, the secondary transmitter (ST) passively senses the spectrum and transmits its own information over those inactive subcarriers of the primary network to the secondary receiver if the signal-to-noise ratio of the PT→ST link is above a predefined threshold; otherwise, the ST stays in silent mode. Two different types of maximum-likelihood (ML) detectors are designed for the primary network, based on the knowledge of either the estimated channel state information or the statistical channel information of the secondary network. A complexity-reducing method, which is applicable to both types and achieves near optimal performance, is further proposed. To evaluate the performance, a tight upper bound on the bit error rate (BER) is derived, assuming the first type of ML detection. Simulation results corroborate the analysis and show that OFDM-IM-CR has the potential of outperforming OFDM-CR and OFDM-IM-AF in terms of BER with higher spectral efficiency.