Harriet Harman is the new deputy leader of the Labour Party, after a seven-week contest to replace John Prescott.
The 56-year-old justice minister pipped favourite Alan Johnson and four other MPs to win the ballot of party and union members, Labour MPs and MEPs.
She got 50.4% of votes to Mr Johnson's 49.6% after all the other contestants' second preferences were reallocated.
She will also become party chairwoman, Gordon Brown announced as he succeeded Tony Blair as Labour Party leader.
Mr Brown, who takes over as prime minister on Wednesday, paid tribute to Ms Harman as he accepted the leadership unopposed.
DEPUTY LEADER RESULT
1. Harman: 50.4%
2. Johnson: 49.6%
3. Cruddas: Out
4. Benn: Out
5. Hain: Out
6. Blears: Out
The final result comes after eliminated contestants' second preferences reallocated
The deputy contest used a complicated system where the last place candidate was eliminated in a series of rounds, and their second preferences reallocated until one contender got more than 50% of the vote.
In the first round she was first choice among Labour Party members, second choice among MPs and MEPS, but the fifth choice of union members.
Ms Harman did not take the lead or pass the 50% mark until the fifth round of voting when she overtook Mr Johnson, as more of Jon Cruddas's backers put her down as their second choice.
She told the BBC: "It was a close race, but I'm delighted to have won it."
Ms Harman, the wife of senior Transport and General Workers' Union official - and Labour Party treasurer - Jack Dromey, has close links to Mr Brown.
Her election completes a remarkable comeback from 1998 when she was sacked from Mr Blair's first Cabinet after public disputes with her minister Frank Field.
Despite that setback she managed to return to the Labour frontbench in 2001 when she became the first female solicitor general.
She told the conference it was an "honour and a privilege" to be elected and to serve alongside Mr Brown.
Ms Harman talked about the achievements of the Labour government over 10 years, paid tribute to Mr Blair and her predecessor Mr Prescott, who she said would be a "very difficult act to follow" and thanked her fellow contenders.
Family: Married, three children
School: St Paul's Girls School, London
Political hero: Rosa Parks
Good night out/in: Get together with the family, with me cooking
Hobbies: Cooking, family get-togethers
Favourite book: We Need To Talk About Kevin, by Lionel Shriver
Best thing on TV: 24
Bad habits: Watching the news too much
Something we don't know about you: After 25 years in politics there is very little
She also told the conference the government should acknowledge the anger felt over Iraq, but at the same time support British troops.
She pledged to be "relentlessly focused" on winning the next general election, by appealing to a broad base of voters, from Middle England to Labour's heartlands.
And she added: "Labour is and must remain the party of the family. I have always tried to be a champion for women and as deputy leader that is what I will do."
Later she told the BBC that the victory had meant a "great deal" to her, adding: "I always thought that the right leadership team for the Labour Party was one that encompassed the north and south, that was the balanced team of a man and woman working together."
During the deputy leadership campaign she had called for an end to the "culture of spin".
On Sunday she reiterated calls to make announcements to Parliament first, adding: "I think it is really important that we turn over a new leaf now."
Mr Johnson, who came a close second, told the BBC he was not disappointed for himself, but was disappointed for his campaign team.
He said Ms Harman would be a "very good deputy leader" adding: "I think there was a big view in the party that it needed to be a woman."
Education Secretary Mr Johnson came a close second
Earlier Mr Prescott, who has been both deputy leader and deputy prime minister, said his successor should concentrate on revitalising the party - not on holding a Cabinet post.
It is seen as unlikely that the two roles would be combined again.
Indications are that Commons leader Jack Straw - who has run Mr Brown's leadership campaign - would get some of the responsibilities of the deputy prime minister's job, but there would not be a deputy PM.
While Mr Brown was the sole contender to replace Mr Blair, there was a more crowded field for the position of deputy leader.
International Development Secretary Hilary Benn, Labour chairwoman Hazel Blears, backbencher Jon Cruddas, Northern Ireland Secretary Peter Hain and Education Secretary Alan Johnson all took part in the contest.