Pedro, a 79-year-old coronavirus patient in Badajoz, southwest Spain, had tested positive for Covid-19 five times and was feeling down after showing symptoms for 46 days.
Carlos Hernández Teixidó, a doctor at Badajoz University Hospital, turned to Twitter for help after struggling to lift Pedro's spirits.
"He is despondent and ready to throw in the towel," tweeted Hernández Tuesday. "Twitter, do your magic."
The response was overwhelming, and the doctor received more than 8,100 replies, plus direct messages. The post also attracted more than 31,000 likes and thousands of retweets.
"I have just spoken to Pedro and his daughter," Hernández told his Twitter followers less than 24 hours after his initial post. "You don't know how moved both of them were. I have given his daughter the first 300 messages."
Pedro is feeling "much better" and his granddaughter will read him the rest of the messages from Twitter, said Hernández. "You are incredible!" he added.
In all, Hernández received more than 15,000 direct messages for Pedro, he told CNN Thursday.
"Not just messages but people have sent pictures, videos, some even played music to try and cheer him up," he said.
"We decided to post the tweet to try and get around 15 people to send him a message to lift his spirits," Hernández said, confessing he was very surprised at the outpouring of support.
"We posted it at 3 o'clock in the afternoon and by midnight we had 300 messages, including from some celebrities in Spain."
The thousands of messages came not just from Spain, but also from neighboring Portugal and other places in Europe as well as Latin America, including Mexico, Colombia and Costa Rica.
The phrase "Hola Pedro" ("Hello Pedro") even became a trending topic on Twitter in Spain.
Pedro has several underlying conditions and had spent around a month at Badajoz University Hospital after being diagnosed, said Hernández.
His condition improved, but repeated positive tests for Covid-19 mean he has had to remain isolated at home without seeing his wife or family.
"I spoke with him a little bit today and he is in very good spirits," Hernández said, explaining that for people in Pedro's situation this sort of support "is almost like providing treatment with a drug."
But the doctor added that, while Pedro's condition has improved, his most recent test -- the sixth -- also came back positive for Covid-19.
Spain has been hit badly by coronavirus, recording the second highest number of cases worldwide and registering more than 24,200 deaths, according to figures collected by Johns Hopkins University.
Prime Minister Pedro Sánchez announced a transition to a "new normality" on Tuesday.
From May 4 residents will be progressively allowed to resume activities after being confined at home since March 14 as Spain was hit hard by the pandemic.
The process is expected to continue for up to eight weeks.