Facebook posted a better-than-expected quarterly revenue of $10.33bn, up 47% from the previous year, on the same day that the social network faced a grilling from US lawmakers over Russian interference in the 2016 US elections.

However, Facebook’s CEO, Mark Zuckerberg, warned that his company’s efforts to clamp down on foreign interference in elections could damage future profits.

“We’re investing so much in security that it will impact our profitability. Protecting our community is more important than maximizing our profits,” he said.

Facebook, Twitter and Google have been under increasing pressure to identify and disclose the ways state-backed Russian operatives exploited their platforms through advertising and divisive political messaging and all three were summoned to testify before Congress this week.

“What they did is wrong and we are not going to stand for it,” Zuckerberg said in reference to the Russian ads as he opened the earnings call with an unusually impassioned statement.

“Our community continues to grow … and we saw good results in the business … but none of that matters if our services are used in a way that don’t bring people closer together – or if the foundation of our society is undermined by foreign interference.

“We’re bringing the same intensity to these security issues that we brought to any adversary or challenge that we’ve faced,” he said.

To achieve that goal, Facebook plans to invest in doubling the number of people (mostly contractors) working on safety and security from about 10,000 to 20,000 in the next year.

Facebook’s chief financial officer, David Wehner, said that expenses would go up 45% to 60% in 2018 to pay for improved security, an expanded video offering and to fund big bets such as artificial intelligence and virtual reality. The company’s quarterly costs and expenses were $4.9bn.

The political controversy in the wake of the 2016 election did not cause advertisers to lose faith in Facebook in the last quarter, with profits jumping by 79%.

Ninety-eight per cent of Facebook’s quarterly revenue ($10.14bn) came from advertising, while an additional $186m came from “payments and other fees”. The company disclosed that more online marketers were buying Facebook’s ads to target messages at mobile internet users.

Facebook’s ability to precisely target digital ads at users based on their interests and other online behavior is so powerful that some lawmakers want to regulate its ability to sell political advertising out of fear that it could play a part in undermining the democratic process.

Facebook turned over more than 3,000 ads to Congress as part of the investigation into Russian interference in the 2016 presidential election and revealed that as many as 126 million Americans may have seen divisive Facebook posts created by Russian operatives. The company also announced measures to improve transparency around political advertising, including creating a searchable database of images and messages used in ads and information about how each one was targeted.

Neither Zuckerberg nor the CEOs of Google and Twitter, Sundar Pichai and Jack Dorsey, attended the congressional hearings. Instead, they were represented by their general counsels.