We have operated a Medipix2 CMOS readout chip, with amplifying, shaping and charge discriminating front-end electronics integrated on the pixel-level, as a highly segmented direct charge collecting anode in a three-stage gas electron multiplier (Triple-GEM) to detect the ionization from $^{55}$Fe X-rays and electrons from $^{106}$Ru. The device allows to perform moderate energy spectroscopy measurements (20 % FWHM at 5.9 keV $X$-rays) using only digital readout and two discriminator thresholds. Being a truly 2D-detector, it allows to observe individual clusters of minimum ionizing charged particles in $Ar/CO_2$ (70:30) and $He/CO_2$ (70:30) mixtures and to achieve excellent spatial resolution for position reconstruction of primary clusters down to $sim 50 mu m$, based on the binary centroid determination method.