For a result which seemed to knock the major parties for six, you didn't need to spend too long on the ground in Bradford to see that George Galloway was capable of giving Labour yet another black eye in Thursday's byelection.

The clues were all there. The first-time voters shimmying up trees to hang Respect banners at the perfect height for anyone sitting on the top deck of a bus. The taxi drivers competing to see who could cancel their Labour party membership first. The queue of students waiting patiently to have their picture taken with their arms around his shoulders as if he was Brad Pitt. All this and more suggested that writing Galloway off as a narcissistic has-been would be a dangerous mistake in this particular electoral contest.

Humiliation

And so it proved, just after 2.30am on Friday, when the returning officer at the Richard Dunn sports centre announced the result Labour had never really accepted could become a reality: seven years after humiliating Oona King by demolishing her 10,000 majority in Bethnal Green and Bow, Galloway had done it again, and by no small margin. He called it the "Bradford spring". The Respect politician had annihilated the Labour vote, winning a 10,140 majority. More than 18,000 people in Bradford West put a cross next to his name; more or less the same number who voted for the incumbent, Marsha Singh, at the last general election. It made Friday one of the most difficult days of Ed Miliband's leadership. Labour had held the seat since 1974.

When Galloway eventually emerged from the leisure centre at 3am, he was greeted by more than 100 supporters who had been waiting out in the cold for hours for a glimpse of their new MP. After loudly booing anyone wearing a Labour rosette, they scooped up Galloway – whose small stature belies his enormous personality – and carried him aloft like a football captain who had taken his team to an FA cup triumph.

"RE-SPECT! RE-SPECT!" chanted his patient fans, adding, "George for prime minister!"

He was then driven into town in a Hummer – the armoured car favoured by Arnold Schwarzenegger when he was governor of California – where hundreds of supporters had been waiting for him since the polls closed at 10pm. Car horns honked to celebrate his arrival at the campaign HQ in Grattan Road. Galloway climbed on top of a grey car and was handed a megaphone to preach to the assembled faithful.

"All praise to Allah!" he yelled, to jubilant cries of "Allah Allah!" And on it went. "Long live Iraq! Long live Palestine!"

Those who voted for Galloway tended to have a number of things in common. They were either a first-time voter or a disaffected Labourite, and all wanted to congratulate him on his robust stance against the wars in Afghanistan and Iraq. Many said they watched him on Press TV, the English language Iranian-controlled channel – until it was taken off air by the government earlier this year.

More still had watched YouTube clips of Galloway ripping into his detractors, whether in front of the US senate in 2005 or in a classically adversarial interview with Sky News about Gaza. Galloway proudly refers to these as his "greatest hits". Only a handful recognised him primarily from his appearance on Celebrity Big Brother in 2006, when he dressed in a red unitard and pretended to be Rula Lenska's pussy cat.

"He is the only politician who tells the truth and fights for justice," said Saeeda Naz, a trainee teacher who was one of the army of Muslim women who worked around the clock for three weeks to persuade their "sisters" to vote. It was thanks to them that a stream of veiled, headscarved women could be seen heading into polling stations across the city, many voting for the first time.

"Yes, he is a professional politician and yes, he is not from Bradford," said one man waiting outside the count. "But they all are. The difference is that this man will represent the views of the ordinary people here. He will address corruption and impotence in Bradford – cynics, thieves, robbers like you get in cowboy films."

'Massive dissatisfaction'

As his victory sank in on Friday morning, Galloway said his triumph was a sign of "massive dissatisfaction with the political system in this country and the main political parties and their leaders".

Using a metaphor he employed repeatedly during the campaign, he said: "If a backside could have three cheeks then they [the main parties] are the three cheeks of the same backside. They support the same things, the same wars, the same neoliberal policies to make the poor poorer for the crimes of the rich people. And they are not believable. Nobody believes what they say. Whether people agree with me or not, I have all of my life said the same things. I mean what I say and I say what I mean. I think people are looking for political leaders like that."

A common theme on the stump was frustration at clan politics in Bradford, known by the Urdu word Bradree or Biradiri, meaning brotherhood or family, which here has become a byword for exclusivity.

Many felt that too many important decisions were taken in Bradford by a small number of Pakistanis who came from Mirpur, a small town in Kashmir, who had carved up the most important Labour party positions between them over the years.

The Labour candidate in the byelection seemed to many to fit exactly into that mould. Imran Hussain, a 34-year-old barrister from Bradford with Mirpur heritage, was following in his father's footsteps when he became involved in the local Labour party, rising two years ago to become deputy leader of the city council.

When the Guardian joined him on the stump in the Allerton ward last week, the contrast between the reception he received and the way Galloway was hailed on the university campus could not have been starker. He didn't appear to be converting any voters but was instead preaching to the converted: those who had voted Labour all their lives and always would.

Galloway, meanwhile, was unleashing all the charm in his substantial armoury to win the hearts and minds of Bradford, lavishing particular care and attention on the younger voters, especially those who had never bothered going to the ballot before. Outside the count, dozens of men told the Guardian they had voted for the first time that day. "I've never voted in my life – I'm 32. I didn't believe in 'em. They're just after the cheque. They just want the cash. End of," said one, as his friends yelled, "He didn't know how to vote!" and "He didn't even know whether to put a cross or a tick." The man nodded. "It's true! But George said, here you go, put a cross by number 2 [on the ballot paper]."

While Galloway turned up to every hustings, guns blazing, his Labour counterpart shied away. The Labour spin machine swore blind it was because they felt Hussain could shore up support better wearing out his shoe leather on the streets of Bradford. But, like almost anyone else in the world, their man, far from your typically silver-tongued barrister, would be no match for Galloway in a debate. The one time the two did meet, on the Sunday Politics show, Galloway wiped the floor with his opponents. "Do you want a local councillor, or an MP?" he asked.

The 57-year-old repeatedly denied he was a divisive figure stirring up racial and religious tensions – "It was Labour who put up a Pakistani Muslim candidate, not us," he said after his victory. He told anyone who dared suggest that he opportunistically targeted Muslims that they were being racist, or at least discriminatory.

"To suggest all Muslims vote for me is to suggest they are second-class citizens who vote like herds of sheep," he said. But he clearly played to the 38% of Muslims who made up the constituency at the last count (in the 2001 census). He caused outrage by sending out a letter addressed to "voters of the Muslim faith and Pakistani heritage in Bradford West" appearing to suggest he was somehow a "better" Muslim than Hussain. "God KNOWS who is Muslim. And he KNOWS who is not. Instinctively, so do you. Let me point out to all the Muslim brothers and sisters what I stand for," he wrote, giving a series of four reasons which included "I, George Galloway, do not drink alcohol and never have. Ask yourself if the other candidate in this electioncan say that truthfully." Galloway has never converted to Islam, though lots of his supporters in Bradford West appeared to be under the impression he had.

Yet in the early hours of Friday morning as he celebrated in the street with hundreds of young supporters, Galloway made a slip-up which would suggest to any practising Muslim that he was not one of them: he invited them to join him at noon for a tour of Bradford on an open-top bus. It was only when someone called out "what about Jumu'ah?" that Galloway realised his victory parade clashed with Friday prayers. The tour was duly postponed until 2.30pm.

But he never held back on the religious imagery. Reflecting on his victory in the early hours of Friday morning, he said we had witnessed something "miraculous" – in the biblical sense of the word. "And as a religious man, I have to believe that there is some divine intervention in this – the retribution of the main parties for the treason against the country and against their supporters that they have visited is something sacred. Justice has been done."

Galloway may have won 56% of the vote, but a sizeable minority of the city viewed his victory with horror. As he was about to board his victory bus on Friday afternoon, one young white man pelted him with eggs. He missed his target but could be heard denouncing Galloway as a "parasite in this city".

Another of his new constituents, an unemployed white woman called Sally, gave him the finger as his bus passed her stop by the town hall. "I think he is more interested in raising his own profile than helping Bradford," she said.

She admitted to taking drastic measures to register her disgust at the ballot box: she was one of 111 Bradfordians who voted for Howling Laud Hope of the Monster Raving Loony Party.