Twitter Inc. agreed to acquire mobile-advertising exchange startup MoPub Inc., in a deal that adds real-time bidding to the microblogging service’s ad platform.

Twitter paid about $350 million in stock for MoPub, in what would be the largest acquisition for the San Francisco-based company, said people with knowledge of the purchase who asked not to be identified because the discussions were private. The deal was disclosed in blog postings from both companies yesterday, and technology blog TechCrunch earlier reported the acquisition and price.

Twitter is bolstering its advertising options as it works toward a goal of $1 billion in revenue by 2014. The company, which is one of Silicon Valley’s top candidates for an initial public offering, has held preliminary talks with securities firms about going public, people with knowledge of the plans have said. Twitter is awaiting third-quarter financial results before deciding whether to file the IPO paperwork with regulators this year or next, the people have said.

MoPub, also based in San Francisco, has almost 100 employees worldwide, according to its post. The startup specializes in helping companies quickly match publishers with ads on mobile devices.

“We look at it as a big bet on the mobile ecosystem,” Kevin Weil, Twitter’s vice president of revenue product, said in an interview. “It’s growing incredibly quickly. We think mobile advertising is in the early stages, and Twitter and MoPub together give us the opportunity to help drive what mobile advertising becomes.”

Twitter said it will continue to invest in MoPub’s traditional services that help place advertisements in applications on smartphones that include Apple Inc.’s iPhone and those using Google Inc.’s Android software.

MoPub’s investors include Accel Partners and Harrison Metal Capital.