Elway, who rewrote the Cardinal record book during his tenure in Palo Alto, Calif., from 1979-1982, will become only the third Stanford player to have his number retired.
"I am extremely humbled that Stanford has chosen to recognize me in this very special way," Elway said in a statement. "It's a tremendous honor to join Cardinal legends Ernie Nevers (No. 1) and Jim Plunkett (No. 16) with this distinction."
Elway threw for 77 touchdowns and completed 62 percent of his passes in his career. He holds the school record for most TD passes in a game with six, which he set in 1980 against Oregon State.
Elway went on to a storied career with the Denver Broncos and is currently executive vice president of the NFL franchise.
Stanford said No. 7 has been in demand in the years since Elway wore it.
"Like Frankie Albert and Jim Plunkett before him, John's greatness set the standard for quarterback play for a generation of athletes," football director David Shaw said.
"Through the years the No. 7 has meant so much to the Stanford community, most recently with the record-breaking career of Toby Gerhart. Current student-athletes Ty Montgomery and Aziz Shittu both will wear the No. 7 jersey and be the last two to put it on for Stanford University," Shaw said.
Montgomery, a junior wide receiver, and Shittu, a sophomore defensive end, are both listed as wearing No. 7 on the Stanford pre-season roster.
Stanford has previously retired the jerseys of Nevers, who rushed for 114 yards in the 1925 Rose Bowl against the Four Horsemen of Notre Dame and went on to play both football and baseball professionally, and Plunkett, who won the Heisman Trophy in 1970 and led the Oakland Raiders in two Super Bowls.
'SNL': 'Anchorman 2' cast, One Direction sing 'Afternoon Delight' [VIDEO]
Selena Gomez drops F-bomb, walks off stage during Jingle Ball performance