In the small hours of Friday May 5, the only smiles were on Labour faces as council seat after council seat turned red. By the time dawn broke, the Lib Dems and Tories had been humiliated and Labour were the undisputed winners.

Across most of England, such an outcome would have been a pipe dream, on a night when voters were determined to give the government a bloody nose. But it really happened in the south London borough of Lambeth, where the electorate bucked the national trend and swung heavily back to Labour.

In the run–up to May 5, Labour, with 29 seats, had some hope of overhauling the ruling coalition of Lib Dems with 27 and Tories with seven. But no–one anticipated the scale of what was to come. One surviving Lib Dem councillor told me of the shock in the party’s camp that night: ‘We were all saying to one another, how the f**k did this happen?’

Today, Labour holds 39 seats to the Lib Dems’ 17, Tories’ six and Greens’ one. Although much of the against–the–odds success was down to very local factors, there are four lessons from the outcome which apply to politics in the rest of the country.

First, Labour beat the Lib Dems at their own game, appointing ‘action teams’ in target and split wards to attend local meetings and take on casework well ahead of the elections.

Second, six months of voter identification, both door-to-door and by phone, identified 1,500 to 3,000 Labour supporters in each target ward. My Lib Dem source conceded: ‘Labour was much better able to get out its vote than in 2002. There was a big increase in their turnout, particularly on the estates.’

Third, Labour successfully blamed the Lib Dems for council failings – a £3m fraud by a town hall official, poor housing, threats to shut swimming pools and bonuses paid to parking wardens who issued the most tickets.

Fourth, negative campaigning worked. Labour put out letters from a Lib Dem defector, telling residents to vote for anyone they liked as long as it was not the Lib Dems. Both sides admit it was effective.

The strategy was carefully planned in the wake of Labour’s surprise defeat last time around, in 2002. The result shows how strong organisation, hard work and the choice of the correct campaigning issues can allow a party to overcome unfavourable national conditions and a run of bad headlines to win at a local level.

One lesson from the strong performance of the British National party at the local elections is that there is bound to be resentment where there is not enough social housing to go around.

Another lesson is that the BNP do not win where turnout is very low, as some maintain. They win where they can motivate habitual non–voters to get out and vote for the far right; and as a result, turnout tends to rise sharply in areas where the party picks up support.

But for me, the main lesson is the importance of mass membership to political parties. In Burnley, when the BNP broke through in 2002, it was helped by the Conservatives and Liberal Democrats being unable to find even paper candidates to contest every seat. In Barking and Dagenham, where the BNP won 11 seats this time around, voters in one ward were faced with a choice on their ballot paper of Labour, the BNP or UKIP.

Even more tellingly, the BNP itself suffered from its lack of mass membership and a shortage of people willing to make themselves social outcasts by standing as its candidates. If it had put up a full slate in Barking and Dagenham, it would have had a fair chance of taking control of the council (although ‘control’ in this case would have been a poor choice of language; it is hard to imagine the chaos they would have brought).

With Labour’s membership down by half since 1994, and members unhappy over everything from the Iraq war to paying for Cherie’s hairdresser, rebuilding the party will be the first challenge for Tony Blair’s successor.