On irregularities, the judge faulted the returning officer for opening ballot boxes which had already been sealed contrary to the law.
The court noted that a huge number of voters in Wajir are illiterate and were assisted to vote.
However, it was wrong for the presiding officers to ask voters to shout the name of their preferred candidate. He said this compromised the voting given the inter-clan rivalry.
Justice Mabeya further said that a scrutiny confirmed that many forms were not genuine because they did not either have watermarks or were either photocopies or printouts.
He faulted the election commission for failing to produce the original forms.
The court ordered a by-election to be held in accordance with the constitution and electoral laws.
The petition was filed by former Wajir Governor Ahmed Abdullahi of ODM party.