The United States, where McDonald's gets about 45 percent of its sales, has been under pressure as cash-strapped consumers have cut back on spending due to rising food and fuel costs.
But $1 beverage offers and marketing focused on the company's Big Mac hamburger helped lift U.S. same-store sales, up 6.7 percent, the largest since a Leap-Day-inflated 8.3-percent gain in February, the company said.
Analysts had been expecting a July same-store sales increase of 4.5 percent to 6.4 percent globally and 4 percent to 4.5 percent in the U.S., according to three analysts' research notes.
The company has also benefited as U.S. consumers trade down from casual dining chains when they do eat outside the home. Casual dining has been particularly hard hit by the U.S. slowdown, as evidenced by the bankruptcy of Bennigan's and other chains.
"There probably is some continuing trading down," John Owens, restaurant analyst at Morningstar, said. "I think that they are also gaining share in the fast-food space as well."
Owens noted that McDonald's also appeals to consumers because of the ubiquity of the chain.
"In this time of high gas prices, McDonald's, with its large footprint in the United States, is probably one of the closest restaurants to your home," he said.
UBS restaurant analyst David Palmer said that the items driving U.S. sales, such as Southern-style chicken sandwiches, breakfast items, iced tea and iced coffee also carry lower than average costs, which should help boost McDonald's margins.
"We believe that beverage sales are a key reason for McDonald's increasing outperformance of the U.S. fast food industry in the summer months," Palmer said in a research note.
Same-store sales rose 7.6 percent in Europe, and 7.2 percent in the Asia/Pacific, Middle East and Africa division. Latin American same-store sales were up in double digits, the company said.