Weighted median filtering is a fundamental operator in a great variety of image processing and computer graphics applications. This paper presents a novel real-time weighted median filter which smoothes out high-frequency details while preserving major edges. We define a new 4D bilateral grid by incorporating the 3D bilateral grid with an additional range dimension. The edge-aware weights and the weighted median values are computed in the 4D space. The proposed algorithm is highly parallel, enabling real-time GPU-based edge-aware implementation. Experimental results show that our algorithm can be run efficiently in real-time on modern GPUs. Applications including JPEG artifact removal and image stylization are demonstrated to verify the feasibility of the proposed weighted median filtering algorithm.