Mark Hunter saw off a Conservative challenge by a majority of 3,657, while Labour suffered the humiliation of losing its deposit.
The Conservatives had mounted an aggressive campaign to win back the Greater Manchester commuter seat, which had been held by the Liberal Democrats in the past two general elections.
Mr Kennedy has been under pressure in recent weeks, with MPs privately expressing concern about his party's failure to make progress since the election.
Had the party lost the by-election, caused by the death from cancer of Patsy Calton, his leadership could have faced a crisis of confidence. In a sign of the contest's importance, Mr Kennedy paid six visits to the constituency to shore up the party's vote.
Mr Hunter, leader of Stockport Council, picked up 19, 593 votes, well ahead of the Tory candidate Stephen Day, who was MP for the constituency between 1987 and 2001, who won 15,936. With just 1,739 votes, Labour came a distant third.
The Conservatives, who have not captured a seat from another party in a by-election for 23 years, had high hopes of winning back Cheadle, which was their top target at the general election. Their defeat is a fresh set-back for the party, which is set to elect a new leader in the autumn.
Mr Kennedy will now attempt to silence disquiet over his own leadership with a major speech on Monday in which he will set out his vision for the party. He is expected to use the opportunity to assert his authority.
Meanwhile, the British National Party lost a bitter council by-election last night after running a campaign that linked the London bomb blasts to immigration.
Labour's Alok Agrawal won a majority of almost 800 votes over the far-right party in the contest in the east London borough of Barking and Dagenham.
The BNP sparked outrage shortly after the explosions by distributing leaflets featuring a photograph of the No 30 bus blown apart at Tavistock Square. The headline read: "Maybe now it's time to start listening to the BNP."
The BNP had targeted the east London borough, traditionally strongly loyal to Labour, as fertile territory for its anti-immigrant message. Largely white and working class, the area has experienced a sharp increase in its ethnic minority population in recent years.
If John Luisis had won for the BNP, he would have become its only councillor in the capital after the party lost a neighbouring seat in Barking last month. It briefly held a council seat in Tower Hamlets in the early 1990s. Last night's result will fuel hopes among opponents that the party has peaked in popularity in London.
- More about:
- Barking And Dagenham
- British National Party
- Conservative Party
- Liberal Democrat Party
- Tavistock Square