Hamas official: Gaza militants agree to ceasefire