NEW YORK — Barry Diller’s IAC/InterActiveCorp agreed to buy from The New York Times Co. for $300 million in cash, letting the company expand its informational website business.

The deal is expected to close in the next several weeks, Times Co. said Sunday. IAC outbid Answers Corp.’s $270 million offer, a person with knowledge of the matter said.

“This sale will allow the Times Co. to focus on the development and growth of our core brands locally, nationally and on a global scale,” Chairman Arthur Sulzberger Jr. said.

Advertisement - Continue Reading Below, which relies on freelancers to produce stories and how-to videos on topics such as making a stir-fry or preventing a tattoo from stretching, has struggled to attract traffic and advertising dollars. IAC’s revenue from and other search-related sites rose 46 percent to $348.8 million last quarter.

Greg Blatt, chief executive of IAC, said joining would help make more profitable.

Times Co. has been unloading businesses and tightening the focus on its main media brand. It sold its stake in Fenway Sports Group, owner of the Boston Red Sox, for $93 million this year and completed the sale of its regional newspaper division for $143 million. The publisher still owns The Boston Globe and Worcester Telegram & Gazette newspapers.

Times Co. purchased for $410 million in 2005.

IAC runs dating sites and OKCupid and has a controlling stake in Newsweek/Daily Beast Co.