In an interview with The Times newspaper, Beckham said the Manchester United manager was a tower of strength as he dealt with national vilification.
The comments came after Ferguson said Beckham had become fame-obsessed and thought he was bigger than his boss.
Beckham was sent off in England’s second round match against Argentina for kicking out at opponent Diego Simeone, in a game England went on to lose on penalties and go crashing out of the tournament.
The midfielder was demonised the following season with Beckham receiving death threats and being booed by away fans, while effigies were hung and torched.
But the midfielder came second in FIFA’s World Player of the Year vote as he helped United to win the English Premier League, the FA Cup and the Champions League.
“Sir Alex was fantastic,” Beckham said.
“He gave me huge strength with his support after the sending-off. The United fans were huge, too.
“In some ways, I am glad I went through it. It made me stronger. When people criticise you, it is not a reason to give up, but to work harder and believe in yourself.”
Describing the extent of his vilification, Beckham said: “Nothing could have prepared me for what happened.
“When a guy broke into my back garden late at night to try to intimidate me, it was almost the last straw. There were death threats, too.
“Suddenly, I was one of the most hated men in the country. I remember the first away game at West Ham the following season, I had to be transported into the ground under a police escort. The faces surrounding the team bus were twisted with anger.”
In Ferguson’s autobiography out this week, the Scot said Beckham became obsessed with fame in the latter years of his Old Trafford career.
He said the player’s focus shifted after he married Spice Girls singer Victoria Adams in 1999.
Ferguson said he decided to sell Beckham to Real Madrid after an incident in February 2003 when he accidentally kicked a boot into the midfielder’s face during a post-match argument.
“The next day the story was in the press. In public an Alice band (worn by Beckham) highlighted the damage inflicted by the boot,” Ferguson said.
“It was in those days that I told the board David had to go. The minute a Manchester United player thought he was bigger than the manager, he had to go. That was the death knell for him.”
Beckham retired after playing his last match with Paris Saint-Germain in May.
In his new book entitled “David Beckham”, serialised in The Times, the football icon said he feared Ferguson as a young trainee.
“Alex Ferguson was always at the training ground keeping an eye on things. We feared him and respected him in about equal measure,” the east Londoner wrote.
“He had a ferocious temper, but a real sense of the importance of nurturing talent. We were confident that if we delivered, he would back us.”