Two-time Cy Young Award winner Tim Lincecum agreed to a two-year, $40.5-million contract extension with the San Francisco Giants on Tuesday, avoiding the arbitration process.