After a strong showing in advertising revenues in the second quarter, Facebook's prospects have improved, Mark Mahaney of RBC Capital Markets said Tuesday.
"Look, that was an inflection-point quarter, fundamentally speaking, on a stock that was one of the most controversial in the internet space. So, you put that kind of combination together, you're going to get a pop," he said. "We think this stock can go up to $40, which isn't much upside from here."
Shares of Facebook gained 6.2 percent to close at $37.63, just 37 cents from its initial public offering price.
On CNBC's "Fast Money," Mahaney explained the reasons behind his "outperform" rating on the stock.
"We have almost $1 in earnings next year, a 30 percent-plus earnings grower, maxed out at a 40 P/E multiple," he said. "That's the logic behind a $40 price target."
Mahaney credited the social media giant for its acceleration in revenues.
"This company was caught flat-foot by this massive trend in the internet space toward mobile usage," he said. "It took them about four or five quarters to catch up, but they caught up, and they caught up extremely well. They blew past most people's mobile ad revenue numbers. And they've really kind of shown advertisers that they can get a decent ROI without undermining the user experience by putting ads into people's mobile phone news feeds."
(Read more: Why Facebook stock keeps climbing)
Asked whether he preferred Google or Facebook, Mahaney picked the former.
"The valuation is a lot more attractive on Google," he said, noting that it was growing earnings at 15 to 20 percent and its stock was trading at "a modest premium to the market."
Mahaney also noted Google's local ad performance, integration with Google Maps and attractiveness to advertisers because of its "proven ROI with search."
(Read more: Stocks did what they needed to do: Guy Adami)
"Facebook is still far from proven. I want to be clear about that," he said. "If you look at the two, probably give a slight edge to Google, but it's a slight edge."
Mahaney said that there was "clearly upside opportunity" in Facebook, while also tempering his comments.
"There's a lot of potential fundamental upside at Facebook," he said. "I just want to make sure we don't get carried away here. Still like the stock, but it's a small 'buy' here."
Trader disclosure: On July 30, 2013, the following stocks and commodities mentioned or intended to be mentioned on CNBC's "Fast Money" were owned by the "Fast Money" traders: Guy Adami is long C; Guy Adami is long GS; Guy Adami is long INTC; Guy Adami is long MSFT; Guy Adami is long AGU; Guy Adami is long NUE; Guy Adami is long BTU; Guy Adami's wife, Linda Snow, works at Merck; Karen Finerman is long AAPL; Karen Finerman is long BAC; Karen Finerman is long C; Karen Finerman is long JPM; Karen Finerman is long GOOG; Karen Finerman is long EBAY; Tim Seymour is long BAC; Tim Seymour is long INTC; Tim Seymour is long SBUX; Brian Kelly is long Yen; Brian Kelly is short US dollar; Brian Kelly is short Copper; Brian Kelly is short Silver; Brian Kelly is short British Pound; Brian Kelly is short Aussie; Mark Mahaney is long TRLA; Mark Mahaney is long EBAY; Mark Mahaney is long EXPE; Mark Mahaney is long FB; Mark Mahaney is long RATE; Mark Mahaney is long GOOG; Mark Mahaney is long IACI; Savita Subramanian is long BAC.