Sampras, who reclaimed the top spot from Australia's Pat Rafter by reaching the final, fought off a set point in the second set to win 7-6, 7-6.
After playing in his first tournament since beating Agassi in the Wimbledon final to capture his 12th Grand Slam title, Sampras said, "It was two heavyweights going at it today."
Sampras, after winning at Queen's Club and Wimbledon, has taken his match- winning streak to 17. He has also extended his lead over his long-time rival Agassi, winning 15 of their 25 career meetings.
The world No 1 and top seed Lindsay Davenport beat second seeded Venus Williams in the Bank of the West Classic final for the second successive year, completing a 7-6, 6-2, victory in Stanford, California.
Davenport earned pounds 54,000 for the triumph over her American compatriot, winning her eighth match in nine attempts against the 19-year-old by taking her fourth title of the year and 23rd championship of her career.