DENVER - San Francisco Giants pitcher Tim Lincecum had surgery on his left hip Thursday and will need five months of rehab to be ready for the 2016 season.

The operation on the two-time National League Cy Young Award winner was performed in Vail, Colo., by Dr. Marc Philippon. Before the Giants began a series with the Colorado Rockies, Giants trainer Dave Groeschner said Philippon "was pretty confident he'll get back to major league pitching for next season."

Groeschner said Philippon repaired Lincecum's torn left hip labrum during the arthroscopic procedure and addressed a hip impingement or bone build-up that had occurred over time and was the biggest source of discomfort for the pitcher.

"I'm glad we did something," Giants manager Bruce Bochy said. "It's going to give Timmy a little peace of mind to get this behind him"

Lincecum will begin range of motion exercises Friday, Groeschner said, and remain in Vail before travelling to Scottsdale, Arizona, early next week and begin working there with the Giants' physical therapist.

Lincecum, 31, went 7-4 with a 4.13 ERA in 76 1/3 innings this season in 15 starts, the last on June 27.

"Timmy was battling to try and get back to pitch this year," Groeschner said. "He was working really hard. He took a couple cortisone shots six weeks ago. As he continued along to try and throw off the mound and get back and get out there, it just wasn't working.

"He did everything he could to try and avoid (surgery). He wants to get back to being Tim Lincecum. He wanted to get this done now, so he can do that."

Lincecum was the first player to win back-to-back NL Cy Young Awards in his first two full seasons — 2008 and 2009. But he has struggled the past four seasons, going 39-42 with a 4.68 ERA. In this, the final season of a two-year, $35 million contract, Lincecum is making $18 million. He will be a free agent after the season.

Bochy is hopeful Lincecum returns to the Giants, recognizing that decision rests with the front office.

"I love Timmy," Bochy said. " A great teammate, we all know what Timmy has done for the Giants. My door will always be open for Tim Lincecum. That's how much I think about him. That's a decision that's made on the baseball side obviously with everybody. I appreciate what he's done in my time that I've had to this point with him. It doesn't mean that won't continue."