Zillow Inc. will buy Trulia for $3.5 billion in stock, the Seattle-based company said. The deal is expected to close in 2015.

While both popular websites will retain their names and separate sites, their merger will create a giant in the burgeoning business of online real estate listings. Zillow and San Francisco-based Trulia combined had 137 million unique visitors in June, the companies said, far more than their next largest competitor, National Assn. of Realtors-affiliated Move Inc.

The two sites, with their troves of searchable, mappable home listings and other data, have transformed the way Americans shop for homes, giving consumers the sort of information that was long the exclusive domain of agents and multiple listing services.

They generate most of their revenue from selling ads to real estate agents, and Zillow Chief Executive Spencer Rascoff said he sees a big chance to grow that business. The companies' combined revenue amounts to just 4% of the $12 billion spent on real estate advertising annually -- much of which remains offline.

"It's still early days in the world of real estate advertising on mobile and Web," he said. "This is a tremendous opportunity to combine our resources and achieve even more impressive innovation that will benefit consumers and the real estate industry."

Analysts also expect the newly combined company to save money on marketing costs -- Zillow and Trulia compete fiercely and both spend heavily on advertising -- and to gain clout in their negotiations with MLS services and large real estate brokerage firms over listings.

News of talks between the rival companies first broke Thursday. Boards of directors for each company have approved the deal, which will need approval from federal antitrust regulators.

Keep an eye on housing and real estate in Southern California. Follow me on Twitter at @bytimlogan