We are told that at the end of Part IV of the poem, the Mariner notices the beauty of the water snakes in the sea surrounding the ship. It is clear that the Mariner is attracted to them for their beauty and vibrant colours and is overwhelmed by what he sees, so much that he blesses them without knowing it:
O happy, living things! no tongue
Their beauty might declare:
A spring of love gushed from my heart,
And I blessed them unaware:
Sure my kind saint took pity on me,
And I blessed them unaware.
The effect of his blessing of the water snakes is dramatic and immediate - he finds that he can pray again and the albatross falls from his neck and falls into the sea, indicating that now the Mariner has blessed a living thing of Nature, this off-sets his crime in killing the albatross, and thus he is able to pray and the bird, the symbol of his guilt, falls away. Likewise this crucial event is what gets the ship back on course - the Mariner falls into a deep sleep, yet when he wakes, he finds that the ship is being sailed by the reanimated corpses of the crew. Eventually the Mariner realises that a troop of angels is in control of the ship. He falls into a trance, during which the ship magically arrives back at his own country.
Thus it is the act of blessing the water snakes that initiates the process of starting the ship moving again and getting the Mariner back home, with the curse upon him ended.