SAN FRANCISCO — Facebook CEO Mark Zuckerberg lashed out at the U.S. government Wednesday, saying that authorities have hurt Silicon Valley companies by doing a poor job of explaining the online spying efforts of U.S. intelligence agencies.

“Frankly I think the government blew it,” Zuckerberg complained during an onstage interview at the tech industry conference known as Disrupt, a weeklong event where Yahoo (YHOO) CEO Marissa Mayer and other prominent tech executives also spoke out publicly and expressed frustration in person, for the first time, since a series of news leaks revealed the government’s controversial surveillance programs.

“It’s our government’s job to protect all of us and also protect our freedoms and protect the economy, and companies,” Zuckerberg told interviewer Michael Arrington, “and I think they did a bad job of balancing those things.”

He went on to say: “They blew it on communicating the balance of what they were going for.”

Facebook and other Internet companies have been under intense pressure in recent months after a series of news reports that suggest U.S. intelligence agencies have gained access to the online activities and communications involving users of Facebook and other popular services. Some of those reports have suggested that unnamed companies have cooperated with the U.S. efforts, although the details are unclear.

Analysts say those reports could hurt the companies financially, especially overseas, if consumers and business customers believe their sensitive information isn’t safe from government prying.

Along with Google (GOOG), Yahoo and other tech giants, Facebook has insisted it doesn’t give the government free rein to tap into its servers. But the companies also say they comply with legal requests to turn over user information. And they have chafed at national security rules that prohibit them from discussing the details of their actions.

Mayer, who was interviewed on stage shortly before Zuckerberg, said Wednesday that she was proud of her company for waging an early, unsuccessful court battle against government requests for Internet user data, a fight that predated her time at Yahoo.

But she said of those battles, “When you lose and you don’t comply, it’s treason.”

Mayer also indicated sympathy for the government’s efforts to defend against terrorism — saying she agreed with earlier comments by PayPal co-founder Max Levchin, who said onstage this week that government cryptographers and other intelligence workers should not be reviled and deserve respect for trying to keep the country safe.

Arrington had warned tech executives that he planned to ask them about government spying efforts during this year’s Disrupt conference, which is organized by the blog TechCrunch. His onstage interviews during the conference are always closely watched industry events.

Zuckerberg, who was clearly prepared for the question, noted that Facebook joined Google, Yahoo and Microsoft in filing lawsuits this week that seek permission to disclose the number and nature of the user data requests they receive from U.S. intelligence agencies.

The Facebook CEO said the numbers would show that the social network has only provided information about a tiny number of the social network’s 1.1 billion users worldwide. But he complained that the government has not explained its efforts clearly.

It didn’t help the interests of U.S. companies in overseas markets, Zuckerberg added, when the government said, “Don’t worry, we’re not spying on Americans.” He added sarcastically, “Oh wonderful. That’s really helpful” for companies that do business around the world. “I think that was really bad.”

Most of Zuckerberg’s remarks, however, focused on Facebook’s progress over the past year. His appearance was a triumphant milestone of sorts for the 29-year-old CEO, who chose the same conference last year to break a lengthy public silence after the social network’s lackluster stock market debut.

At the time of his 2012 appearance, Facebook’s stock was floundering at nearly half the company’s initial public offering price of $38, as critics questioned whether Facebook could adapt to the mobile Internet trend. Zuckerberg was forced to concede then that Facebook’s stock performance had been “disappointing,” but he vowed the company’s nascent mobile business “will make a lot of money.”

In the year since, Zuckerberg has followed through on that prediction, while presiding over a resurgence in Facebook’s stock. After developing new kinds of advertisements to show within each user’s stream of posts and updates from friends, the company is expected to see more than $2.5 billion in mobile ad sales for 2013, according to research firm eMarketer.

Facebook’s stock hit an all-time high of $45.09 on Monday, before closing at $45.04.

Zuckerberg acknowledged Wednesday that he worried about the company’s initial public offering last year, especially after the stock price plunged. He said he feared that talented employees would become demoralized and leave the company.

They didn’t, he said, adding that the experience “has made our company a lot stronger.”

Facebook’s success has also enabled Zuckerberg to increasingly flex his wealth and clout on public issues: He’s launched a political advocacy group to campaign for new immigration laws and announced a campaign with mobile tech firms to expand Internet access in undeveloped countries. He reportedly is scheduled to meet next week with congressional Republican leaders in Washington, D.C.

Contact Brandon Bailey at 408-920-5022; follow him at Twitter.com/BrandonBailey.