A judge has effectively halted a Scottish Labour candidate selection contest after ruling a ban on new party members taking part was "irrational".
Asim Khan took the party to court after claiming dozens of his supporters were denied the chance to vote for him.
Many of the supporters are from ethnic minority backgrounds, and joined during last year's party leadership contest.
But the party said they could not vote in the Glasgow South West selection contest, in which Mr Khan is standing.
After a hearing at the Court of Session, judge Lord Clark said the decision by the party's ruling body to change the cut-off date for newer members who wanted to take part in the selection contest was "irrational" and the basis for it "wrong in fact and wrong in law".
Scottish Labour said it accepted the ruling and would not be pursuing the case further.
The leadership contest between Richard Leonard and Anas Sarwar last autumn saw a big increase in new members joining Scottish Labour, with trade unionists enrolling to back Mr Leonard and Mr Sarwar signing up people from the Asian community.
Mr Khan, who backed Mr Sarwar, is now standing against Glasgow councillor Matt Kerr, the son of Labour national committee chairman Andy Kerr, to be the party's candidate in Glasgow South West.
The seat will be a key target for Scottish Labour at the next general election after the party lost by just 60 votes to the SNP last year.
Under party rules, anyone who has been a member for six months should be able to vote in the candidate selection contest.
But there has been controversy over the "freeze date" - the day from which the six months of continuous membership is calculated.
Mr Khan argued it should be 4 April, but the party's Scottish Executive Committee ruled it should be 21 March - a decision Mr Khan said would prevent about 80 of his supporters taking part because they had joined more than six months before that date.
Mr Khan told BBC Scotland he was "pleased" with the judge's ruling, but said he was "sorry that it had to come to this".
He said: "I sincerely hope now we can move on to elect the Labour MP that members want, and there will be no further malicious attempts to undermine the process."
Ahead of the ruling, the Politics Home website published a letter from five anonymous Scottish Labour members with Asian backgrounds.
The letter claimed they were prevented from voting in the Glasgow South West contest because of their "names, ethnic and cultural origin" and "how this would influence how we might vote".
The five members also said they had been made to feel "not wanted and not welcome in the Labour Party" since joining during the leadership contest.
The letter has been sent to Scottish Labour leader Richard Leonard and UK party leader Jeremy Corbyn.
Responding to the letter, Scottish Labour said "no applicant who joins is blocked on the grounds of race, religion, sexuality or gender, nor would they ever be".
And the party said its rule book "provides integrity and consistency for all members and potential members."