In this study, a novel compact bandstop filter (BSF) by utilizing the defected ground structure (DGS) and defected microstrip structure (DMS) techniques are presented. DGS, DMS, and compensated capacitors are used on both bottom and top layers to obtain sharp transition and wider stopband. The operating frequency bandwidth of the filter can be comfortably regulated by tuning the dimensions of the etched structures. In addition to parametric studies, an equivalent circuit model of the proposed filter is extracted. The BSF has an insertion and return losses better than -1.6 and -17 dB in the passband, respectively. Moreover, the developed filter covers X-band frequency range and has stop bandwidth of 10.8-11.8 GHz with the rejection of better than 20 dB. Furthermore, the measurement and simulation results are in compliance with the suggested method. The proposed BSF has a very small size of 14.28 mm x 4 mm x 0.508 mm and has the potential to be used for radar applications with its high compactness, low cost, and high harmonic rejection performance.