Google's prospects haven't looked so promising to investors relative to Apple since before the iPhone was introduced.

Google's shares, which climbed to a record Tuesday, are now trading at 25 times profit, compared with a price-to-earnings ratio of less than 10 for Apple, according to data compiled by Bloomberg. That gap is at its widest since June 2005, two years before competition between the two companies in mobile devices began to intensify.

Investors are willing to pay more for each dollar of Google's earnings relative to Apple amid optimism that Google, with more than 40 percent of the U.S. online-advertising market, will command even more of the $37.3 billion that businesses spend each year to reach Web audiences.

Google also has used an alliance with Samsung Electronics to gain share in mobile software, feeding the competitive threat weighing on Apple as investors await the next big product from the iPhone maker.

"There's only one company benefiting from all the growth areas of the Internet - be it video, mobile, local, social, display advertising," said Sameet Sinha, an analyst at B Riley & Co. "Apple has just done well in devices, nothing else."

Google fell less than 1 percent to $831.38 Wednesday, while Apple decreased 1.3 percent to $425.65. Google's U.S. shares have added 35 percent in the past 12 months. Apple has declined 21 percent in the same period, though its market capitalization is still more than $100 billion higher than Google's. Apple remains the world's most-valuable company, followed by Exxon Mobil Corp. and Google.

Under CEO Larry Page, Google has extended a lead in Web search, boosting its share to 67 percent, and in smartphone software, where it commands 70 percent of the market. That helps the Mountain View company benefit from two big shifts - the boom in tablets and smartphones, and the move toward digital advertising.

Apple is undergoing slowing revenue growth and narrowing margins amid accelerating mobile competition led by Samsung and other users of Google's Android operating system. A year and a half after the death of co-founder Steve Jobs, Apple is working to release new products that can build on the successes of the iPod, the iPhone and the iPad, which revolutionized their respective industries.

The changing fortunes underscore the strength and predictability of a growing advertising market, compared with consumer electronics. While ad prices can vary with the strength of the economy, there's usually steady demand for ads generally. In consumer devices, Apple faces pressure to constantly come up with a new home run product, said Nabil Elsheshai, an analyst at Thrivent Financial for Lutherans.

"It's no coincidence that Google's rise has coincided with Apple's demise," Elsheshai said. "Making money from services versus devices is growingly perceived as a better business model."

The outlook for Google has improved since as recently as mid-2011, when the company's shares were trading below $500. The stock came under pressure amid concern that the company would struggle to find growth outside search advertising while grappling with competition from Facebook, Amazon.com and Apple.

Also weighing on Google was regulatory scrutiny by the U.S. Federal Trade Commission, which at the time was embarking on a broad antitrust investigation of its business practices.

The tide has turned, with Google demonstrating an ability to expand swiftly into new businesses, mainly mobile advertising. Google will command 55 percent of the U.S. market for mobile-ad revenue this year and 57 percent in 2014, according to EMarketer Inc.

There's no guarantee Google will remain investors' favored stock. Apple CEO Tim Cook has said the company is exploring TV-related products, and he has a team of engineers developing a wristwatch device, according to people with knowledge of the plans.