Nadal had taken the opening set 6-3, but was down a break in the second set by a 4-3 score having been broken twice when Ferrer called it quits, bringing an end to his Grand Slam career.
Nadal faces Canadian Vasek Pospisil in the second round. The Spaniard won the only career meeting between the pair three years ago in Beijing.
Nadal takes first set comfortably
Nadal, as expected, struck first in the third game as a pair of backhands brought up a break point, taken when Ferrer's own backhand found the net to give the world number one a 2-1 lead.
Neither player was threatened on serve until the ninth game when Ferrer's backhand, normally a strength of his, let him down again to bring up double set point. It was his forehand error that gave Nadal the opening set.
Ferrer retires after picking up calf injury in farewell major match
After taking a break following winning the opening set, the three-time champion in Flushing Meadows was broken to love to start the second set after missing a short forehand into the net.
Nadal immediately broke back and one game later on the changeover, Ferrer called for medical attention on his left calf.
He came out and broke for a second time to take a 3-2 lead.
Each man held and before the eighth game was to be played, Ferrer decided the calf was too much of an issue and decided to shake hands with his good friend, the two sharing a hug in what was the 36-year old's farewell major match.