Ex-PM Gillani cleared to contest elections