The world number five looked the lesser player for much of the contest that he eventually won 4-6, 7-6, 6-4.
"I was lucky to get out of it today," he said.
Bogdanovic, ranked 117 in the world, rattled Roddick by finding the lines on both sides of the court and wrong-footing the American with a powerful backhand.
Roddick was clearly exasperated at his own game, shaking his head, hands on hips between points after sending groundstrokes long or wide.
Bogdanovic broke the famous Roddick serve in the third game and clung on to his lead to take the first set with two big serves of his own.
The pair looked evenly matched throughout the second set with Bogdanovic, 23, saving a set point in the 10th game.
HUMILIATING EXIT
He took the 24-year-old American to the brink in the tiebreak, finally succumbing 7-5 to a Roddick forehand on the line and big serve that he could only return long.
Second-seeded Roddick expected to feel more in command on grass after his humiliating first-round exit at the French Open on clay earlier this month, but it was not until the seventh game of the third set that he broke the British number three's serve.
His experience showed then and he held firm to win with an overhead smash on his first match point.
Roddick meets another wildcard, lofty Croat Marin Cilic in the quarter-finals. Cilic, 18, the top junior in the world last year, overcame French qualifier Jo-Wilfried Tsonga, second-round victor over defending champion Lleyton Hewitt, 4-6, 6-3, 6-2.
Third seed Fernando Gonzalez of Chile advanced stealthily, beating American Robby Ginepri 6-2, 7-5.
Though he commands none of the headlines of top seed Rafael Nadal and Roddick, the Australian Open runner up, ranked sixth in the world, has some grasscourt pedigree having reached the quarter-finals here last year and at Wimbledon in 2005.