Google Inc's quarterly profit topped expectations, helped by cost controls and marketers switching to online ads from traditional media, sending its shares up as much as 5 percent.

Despite the broad-based slump in ad spending due to the weak economy, the No. 1 U.S. Internet search company said paid clicks -- by Web surfers on Google's text-based search ads -- rose 17 percent in the first quarter from a year earlier.

As advertisers are getting better control of their budget and a better understanding of their business under these macro conditions, they are taking money away from newspaper and television and going back online to advertise, and Google gets a disproportionate part of the market, said Sameet Sinha, senior analyst at JMP Securities.

Google reported a net profit for the quarter ended March 31 of $1.42 billion, or $4.49 cents a share, up from $1.31 billion, or $4.12 a share, a year earlier.

Excluding special items, Google earned $5.16 a share, ahead of the average Wall Street forecast of $4.93 according to Reuters Estimates. The figure also beat the whisper number of $5 per share that some analysts and investors were expecting.

Good quarter considering the environment, said Youssef Squali, managing director at Jefferies & Co. Cost containment, including capex, was pretty impressive, which is what's needed to make the stock work short-term.

Shares of Google rose as high as $410 before falling back to $402, still up 3.4 percent from their Nasdaq close of $388.74.

Google also said Omid Kordestani, its senior vice president of global sales and business development, would step down to take a new role as senior advisor to the office of the CEO. Kordestani will be replaced by Nikesh Arora, currently Google's president of international operations.

First-quarter revenue was $5.51 billion, up 6 percent from the year-ago quarter but down 3 percent from the 2008 fourth quarter, the first ever sequential decline in revenue for Google. Revenue was roughly in line with analysts' average expectation of $5.53 billion.

Google Chief Executive Eric Schmidt said on a conference call that the economic environment remained tough, with users still searching but buying less.

Economically speaking, I think Q1 is the most challenging quarter, so the momentum should continue for the rest of the year, said Kaufman Brothers analyst Jason Avilio.

Google said it expected to continue to make significant capital expenditures, but did not provide financial forecasts, following its custom.

(Reporting by Alexei Oreskovic and Anupreeta Das; Editing by Tiffany Wu and Richard Chang)