For much of the last nine years, Zillow and Trulia have competed in the online real-estate listings market they helped create.

But after a speedy six-week courtship, the two will combine forces.

Seattle-based Zillow agreed Monday to buy Trulia for about $3.5 billion in stock, creating a giant repository for online listings for real estate and home values.

Under the terms of the deal, Zillow will pay 0.444 of one of its shares for each share in San Francisco-based Trulia. Based on Friday’s closing prices, the takeover bid is worth $70.53 a Trulia share, a premium of about 25 percent.

News of the deal pushed Zillow stock up $1.46, or 0.9 percent, to $160.32 Monday, while Trulia rose $8.69, or 15.4 percent to $65.04.

Together, the two will dominate the traffic for online home listings. Last month, Zillow reported a combined 83 million web and mobile Internet users, while Trulia reported 54 million — a combined 61 percent of total Internet users for the category, according to comScore.

“The companies know each other very well,” Zillow CEO Spencer Rascoff said by telephone. “We’ve been competitors and rivals for nine years, but I’ve always had respect for them.”

Zillow is one of the best-known players in the market through its widely quoted “Zestimates” of how much a property is worth, a feature particularly popular among existing homeowners. Trulia has tools that tend to draw more of an audience among potential home sellers.

According to Rascoff, that has meant relatively little overlap, with about half Trulia’s web users not visiting Zillow.

Rascoff said he first approached Trulia about six weeks ago. The initial response was not dismissive — Trulia said it had not had any intention to put itself up for sale — but management asked what Zillow had in mind.

“Both companies are coming at this from a lot of strength and momentum,” Rascoff said. “When we approached them, I think they were both very open-minded about it.”

Trulia’s management team, led by Peter Flint, ultimately proved willing to negotiate, but requested an all-stock deal to give their shareholders a chance to benefit from the merger.

Existing Trulia shareholders will own about a third of the combined company. Flint will report to Rascoff, and he and another Trulia director will join Zillow’s board.

Together, the two companies expect to realize about $100 million in cost savings by 2016. The newly enlarged Zillow will have an even bigger platform for sellers and real-estate agents to list home offerings and for advertisers, while combining the two companies’ nascent rental-search offerings.

Still, Rascoff said he did not expect antitrust regulators to object. The revenue of the merged company — $341.2 million last year — represents only a small part of what he reckons is the $12 billion the real-estate industry spends on marketing each year.

Moreover, he argues, the industry is highly fragmented, with scores of local sites for each city.

Both Zillow and Trulia have sought to combat that trend through other acquisitions. Over the last year, Zillow has bought both the New York-focused StreetEasy and the apartment search site HotPads, while Trulia bought Kirkland-based Market Leader last spring for $310 million.

Zillow’s goal, according to Rascoff, is to create a portfolio of real-estate properties, becoming more along the lines of an IAC/InterActiveCorp.

Zillow and Trulia will continue to compete until the deal closes, which is expected sometime next year.