Prime Minister wins court clash on eve of election