Dani Sordo secured his maiden WRC victory after a hard-fought battle with Thierry Neuville at the Rally of Germany.