Dementors played a crucial role as guards of Azkaban, the wizarding prison. They were employed by the British Ministry of Magic due to their ability to drain hope and happiness, making them effective prison guards. They were intelligent enough to follow instructions and even acted as bodyguards for the Minister for Magic. However, their loyalty was fickle and they eventually defected to Lord Voldemort's cause when he was sighted in the Ministry. After the Second Wizarding War, they were dismissed from their posts at Azkaban.