The former Liverpool and Chelsea boss was in the frame to succeed Sam Allardyce at the east London club before he agreed to take charge of Madrid, according to Hammers co-chairman David Sullivan.
West Ham, who Sullivan says were also interested in Jurgen Klopp in the northern summer, ultimately appointed former Croatia coach Slaven Bilic.
"We were two hours from getting Benitez and then Real came in," Sullivan told Sky Sports.
"We had agreed a contract and everything."
Benitez's reign at the Bernabeu has been rocky to say the least, with supporters calling for him and club president Florentino Perez to go after they were thrashed 4-0 by bitter rivals Barcelona in Madrid last month.
In spite of that, Sullivan would have had no reservations about bringing him to Upton Park.
"He is a top manager, whatever anybody says, and I think he'd have done a wonderful job for us," Sullivan said.
"We tried (Jurgen) Klopp as well but he wouldn't come because he said he wanted a break. But I'm glad with the manager we have got."
Sullivan also revealed the club intended to make the signing of Argentinian midfielder Manuel Lanzini permanent.
The 22-year-old is currently on a season-long loan from United Arab Emirates club Al Jazira and West Ham have until April to upgrade the deal.
"The contract we have is 100 per cent watertight," Sullivan added.
"We have until April to make it permanent but we'll probably do it before the due date.
"He is a fantastic player and a fantastic man. By February or March, he will be a permanent West Ham player.
"He could be a top, top, top player. He's already sensational and he could be as good as any player in the world."