Downey was a big fan of Malek's show Mr. Robot and started e-mailing, texting and calling the younger actor.
"This all started -- and this is so surreal -- but I was such a fan of Mr. Robot," Downey said. "I basically e-mailed you and was serial-texting you, I was trying to FaceTime you. You didn't let me weird you out, and now we're friends."
"I couldn't even believe it was you. For a second, I got the e-mail from Robert, and I thought, 'Okay, somebody's playing tricks on me,'" Malek responded. "Then they kept coming, and they were so witty ... that I thought it could be no one else but you.
Malek and Downey became friends, with Downey even visiting Malek on the Mr. Robot set.
"This friendship has continued -- you came to visit me on set, I couldn't believe that," Malek said.
Malek and Downey co-star in the new movie Dolittle, which is primarily based on the Hugh Lofting book The Voyages of Doctor Dolittle. Downey plays the titular Dr. Dolittle in Dolittle, while Malek voices the gorilla Chee-Chee.
Malek had nothing but praise for the film on Ellen.
"It is a truly moving, extraordinary experience," he said.
Also on Ellen, Malek and Downey played the trivia game "Do (You Know a) Little or Do (Ya Know a) Lot."
Dolittle opens in theaters Friday. Malek is known for playing Elliot Alderson on Mr. Robot, which ended in December after four seasons on USA Network, while Downey portrayed Tony Stark, aka Iron Man, in the Marvel Cinematic Universe.