“For my money, this is one of the best pitching staffs in baseball, if not the best,’’ Huff said. “If we get to the playoffs, I don’t see how we don’t have as good a chance as anybody the way Tim and these guys are throwing.’’

With Lincecum reigning as one of the game’s most dominant pitchers, the Giants last year fell five wins short of reaching the postseason for the first time since 2003. This year, with Lincecum, Barry Zito (7-4, 3.45), Matt Cain (6-6, 2.72), and Jonathan Sanchez (6-5, 3.03) anchoring the rotation, San Franciscans are hoping for better, maybe even the franchise’s first World Series title since 1954.

“Things were much more serious around here then,’’ said Lincecum, Cy snuggling at his feet. “We’re a lot more free-spirited now.’’

He joined the Giants in 2007, Bonds’s last year with the team. A month after the season, Bonds was charged with four counts of perjury and one count of obstructing justice in connection with the BALCO steroids scandal. He awaits trial.

Lincecum, who is scheduled to face the Sox today in the series finale, has helped make the Giants contenders again — they trail the Padres by 3 1/2 games in the National League West — with his nasty stuff (8-2 with a 2.86 ERA and 113 strikeouts in 100 2/3 innings) and exuberance.

“Everybody knows this used to be a really stiff place,’’ first baseman Aubrey Huff said. “Now, it’s one of the best clubhouses you could be part of. Everyone is loose and having fun, and a lot of that is Tim.’’

The lockers once occupied by Bonds and frequented by his allegedly corrupt trainer, Greg Anderson, now belong to the shaggy-haired Lincecum and his pet bulldog, Cy.

As the Red Sox visit San Francisco for the first time since their historic season of 2004, there is joy again in Giantsville, thanks in no small measure to Lincecum, otherwise known as The Freak. The kid may look more like a stoner than a stopper, but the former Cape Cod League ace has captured the last two National League Cy Young Awards, succeeded Bonds as the Giants’ greatest weapon, and helped to kill the bad vibe the home run king created.

No more. Five years later, the Giants have a new face, straight out of casting for a sequel to “Dazed and Confused.’’

Those were dark days on the shores of McCovey Cove. Bonds was the face of a franchise crippled by scandal, clubhouse acrimony, and baseball mediocrity.

The kid, Tim Lincecum, was providing meals for mosquitoes in Harwich (“I got eaten alive’’) while Bonds was hunkered down in his tricked-out corner of the San Francisco Giants clubhouse.

SAN FRANCISCO — Five summers ago, a kid with a golden arm was playing baseball on Cape Cod while the feds were closing in on Barry Bonds.

Success is nothing new to Lincecum. The ace for his home-state University of Washington, he arrived for a summer with the Harwich Mariners just after the Cleveland Indians chose him in the 42d round of the 2005 draft. Lincecum’s Harwich teammates recall him rejecting Cleveland GM Mark Shapiro’s reported signing offer of $700,000.

“I remember Timmy saying he wanted to sign for enough money so his dad could retire,’’ recalled Joe Hough, who starred at Catholic Memorial and the University of Maine and was one of Lincecum’s best friends on the Harwich team.

Before Lincecum returned to Washington, where his father worked for Boeing , he tore up the Cape league so thoroughly that he earned the nickname “Doctor Nasty.’’ His biggest setback was suffering a concussion when he was struck in the head by a line drive.

A year later, the Giants signed him as the 10th overall pick for $2 million, to the delight of his Harwich teammates.

“He was everybody’s favorite,’’ Hough said. “He has so much fun playing baseball, it’s scary. Nothing brings him down.’’

Lincecum has infused a similar spirit in the Giants clubhouse, as he and Cy demonstrated before a recent game at AT&T Park. As players killed time before batting practice, one of Lincecum’s largest teammates, reliever Dan Runzler (6 feet 4 inches, 230 pounds), struck a Rockwellian pose as he curled up on a clubhouse couch with Lincecum’s little bulldog.

“It’s a dog’s life,’’ Runzler said blissfully before Cy bounded off the sofa to join Lincecum at his locker.

At a nearby table, a group of Lincecum’s Latino teammates were playing cards, seemingly cut off from the world. Then Cy emitted a foul gaseous odor. The card players, enveloped by the fumes, began gasping for breath and howling in mock distress.

Lincecum played along.

“Oh, my God,’’ he shouted. “It does stink!’’

No sooner did the air clear than Lincecum again became the center of attention. As he chatted about his summer on the Cape, he suddenly snapped into a sneezing fit. For several minutes, the youngest National League pitcher to win consecutive Cy Young awards (he turned 26 June 15) was unable to finish a sentence, sneezing with machine-gun rapidity, his shoulder-length locks flapping with every burst, his teammates reveling in his discomfort.

“Sorry, dude,’’ he said between sneezes. “Allergies.’’

Lincecum’s pitching, however, is nothing to sneeze at. Earlier this month, he logged his 100th career start, hitting the milestone at 44-19 with a 3.19 ERA and 755 strikeouts in 666 1/3 innings. His first 100 starts compare favorably to those of former Sox great Pedro Martinez, who went 46-29 with a 3.01 ERA and 648 strikeouts in 729 2/3 innings.

Lincecum, like Martinez in his early years, has fought the perception that he is too small to sustain his dominance. He is 5 feet 11 inches, 170 pounds, much like Martinez, but he has impressed even Martinez with his array of pitches and command of them.

“He’s amazing,’’ Martinez said last year after he outdueled Lincecum in a 2-1 victory for the Phillies. “He reminds me a lot of me, but twice as better at the same time in the big leagues.’’

Lincecum, having recovered from his sneezing binge, said Martinez has inspired him since his early teens.

“I didn’t look at him in an iconic way,’’ Lincecum said. “It’s more like he was the guy who opened the door for pitchers like me. I used him as an example.’’

The only blemish of Lincecum’s early career was a civil infraction last year for marijuana possession.

“I will try not to let it happen again,’’ he told the judge.

The Giants hope so, considering they may need Lincecum at his best this summer to offset a subpar offense.

Losing Bonds may have ended clubhouse tensions, but no one has come close to replacing him at the plate.

“We have always been a team with sluggers, from McCovey to Bonds, but now we know we have to pitch well,’’ said pitching coach Dave Righetti. “Tim and the guys have taken on that challenge.’’

They also have made playing for the Giants fun again.

Bob Hohler can be reached at hohler@globe.com.

© Copyright 2010 Globe Newspaper Company.