Thomas (Team Sky) secured a repeat overall victory on the uphill finish of Alto do Malhao to cross the line in fifth place in Sunday's final stage.
His consistency throughout the five stage tour gave him a 19 seconds lead ahead of second-placed Ion Izagirre (Movistar) while final stage winner Contador (Tinkoff) was third, a further seven seconds back.
“It was a hard day," Thomas said. "With the strong wind it was even more complicated.
"When Contador attacked I tried to stay calm and not chase him. My main goal was to win the race. This winter i had the most prolonged time in my career off the bike, about five weeks, and I did not know if I was going to be fine.
"I was under a lot of pressure because last year I came to help Richie (Porte) and this year had the lads working for me. It was good to win to thank them."
Contador made a late attack to win in a time of four hours 24 minutes and 47 seconds. He battled Fabio Aru (Astana) in the latter part of the 169 km stage that started in Almodovar to win by 20 seconds, with Thibaut Pinot (FDJ) third.
"I knew I was coming to Portugal in good form," Contador said.
"I hadn't raced since a number of months and on the second stage, I probably lacked a bit of energy in the final part, that's why I lost more time than I would have lost under normal conditions.
"For that reason, for me, today was an important day. I had the legs and I was feeling I could win. That's why the squad worked together with Movistar and we clinched the win."