The Spaniard kept his two-second lead over Italian Fabio Aru in the overall standings.
"It was a hard day for me but I'm happy because I got through it," he told reporters.
"After three and a half or four hours I didn't know what to do with my arm but I hope and trust that, as the days pass, it will improve. Now I'm just thinking of resting and putting ice on my shoulder."
While Contador will be hoping that his damaged shoulder can survive the strain of competing in the mountain stages this weekend, Ulissi was celebrating crossing the line first in the longest stage of this year's race with a time of seven hours 22 minutes 21 seconds.
Spaniard Juan Jose Lobato, who rides for Movistar, finished second in the same time while Australian Simon Gerrans (Orica) was third.
"There are some big sprinters here so I knew I wasn't the number one favourite today," said Lampre rider Ulissi. "I went early because I was afraid of getting caught from behind."
The Italian returned to cycling in March after receiving a nine-month suspension for testing positive for the asthma-inhaler drug salbutamol.
Ulissi's stage victory was the fourth of his career in the Giro d'Italia.
Saturday's 186 km mountain stage will be from Fiuggi to Campitello Matese.
(Writing by Tony Jimenez, editing by Pritha Sarkar)
Share
