He undertook multiple reforms such as: forbidding priests to marry and outlawing the selling of church offices. He also banned the practice whereby kings could appoint priests, bishops and the heads of monasteries.
Henry the IV was mad at the way Gregory ruled so he told the church officials that Gregory should no longer be Pope. Gregory got mad and excommunicated Henry from church.
Henry begged for forgiveness and Gregory admitted him back to church.