White needs to play a waiting move with his king. This will force the black queen to abandon her defense of the rook on g2, and White can capture it, giving mate.
The trick is that not any move will do. Of the five squares available to the white king, four are vulnerable to a check by the black queen, and such a check would prevent White from mating on the next move. Only 1. Ke7 leaves the king safe from attack — now Black must move his queen and lose to 2. Qxg2#. (Moving the rook is no better: 1. Ke7 Rh2 2. Qxf1#.)