After winning Wimbledon a week ago, Federer returned to the top for the first time since June 2010, and his 287th week at No. 1 - one more than Sampras.
The 17-time Grand Slam champion says he is "extremely proud and honored to have beaten Pete's record as he was my childhood hero and I have always looked up to him."
The Swiss star will enter the Olympics next week as the world's top-ranked player.
Sampras says "the hardest thing to do in sports is the ability to stay on top. Roger has been able to do so by great play and durability."