Time Warner Inc. has agreed to buy a 10% stake in video service Hulu, a move that comes as media companies and cable operators contend with viewers increasingly cutting the cord and as Hulu prepares to launch a new online pay-TV service.

Time Warner said it paid $583 million in cash for the 10% stake, valuing Hulu at about $5.8 billion. The new valuation is triple what Hulu was worth in 2012, according to a person familiar with the matter.

Along with the Hulu news on Wednesday, Time Warner also logged better-than-expected earnings results in the second quarter, prompting the company to push up its full-year outlook. But the company’s second-quarter profit and revenue still fell from a year earlier because of slowing revenue growth in its HBO business and box-office weakness.

Time Warner said Wednesday that its channels—including TNT, TBS, CNN, Cartoon Network and Turner Classic Movies—will be available live and on-demand on Hulu’s new cable-style online video service, set to launch early next year. Hulu’s new service, confirmed in May, could further undercut traditional cable providers by offering its “skinny” TV bundle for roughly $40 a month.

Time Warner Chief Executive Jeff Bewkes said on an earnings call with analysts that the investment will “increase our company’s exposure to the secular growth in over-the-top,” or internet TV. He said it would also give Hulu more resources to invest in programming and will help foster “competition and innovation” among streaming services and traditional cable TV distributors.

In November, The Wall Street Journal reported that Time Warner was in talks about becoming a stakeholder in Hulu alongside Walt Disney Co., DIS -2.50% 21st Century Fox Inc. and Comcast Corp. CMCSA -1.28% The deal for a 10% stake doesn’t give Time Warner a seat on Hulu’s board of directors, limiting its role in Hulu’s strategic decisions.

With the investment, Time Warner is attempting to carefully thread the needle in trying to reach younger viewers while not explicitly encouraging cord-cutting.

One sticking point that had to be overcome in talks with Hulu’s owners was that Time Warner wasn’t comfortable with the vast amount of current season content made available on Hulu, believing that the availability of such content for a cheap price encouraged more people to cut the cord. Mr. Bewkes has even been vocal about Time Warner potentially holding back rights to its shows for longer on its own on-demand platforms before selling them to rival streaming services.

As a result, Time Warner’s deal is unusual for a Hulu part-owner: It is only making current-season content available on Hulu’s forthcoming $40-a-month virtual cable-TV service, which will include live channels and on-demand programs. Full current seasons of shows from Time Warner’s networks won’t be available on demand for Hulu’s existing $7.99-a-month service, unlike programs from Hulu’s other owners, Fox, Disney and Comcast’s NBCUniversal.

While the Hulu announcement doesn’t include cable channel HBO, a Time Warner spokesman said there have been conversations about HBO gaining carriage on Hulu, and talks are expected to continue.

New York-based Time Warner—owner of the Warner Bros. film studio and HBO—has been grappling with subscriber declines as more people cut the cable cord and downgrade to cheaper, skinnier bundles of programming. In an effort to cater to cord-cutters, Time Warner last year launched HBO Now, its stand-alone streaming service, and has started offering streaming subscription services around some of its other brands like Adult Swim.

It has also been licensing to new entrants like Dish Network Corp. ’s Sling TV, Sony Corp. ’s PlayStation Vue and, now, Hulu. On the call with analysts, Turner Chief Executive John Martin said that Time Warner is striking carriage-fee deals with the newer players that are comparable to traditional cable and satellite deals—including with annual contractual rate increases.

In the second quarter, revenue fell 5.4% from a year earlier. The decline was largely due to weakness in the company’s Warner Bros. business, where there has been a lack of blockbusters. At the same time, growth in HBO slowed sharply during the quarter, rising just 2% after having climbed 7.7% in the first quarter.

A bright spot was Turner’s performance, with revenue increasing 6.5% as election coverage at CNN and interest in the NBA playoffs drew more advertising dollars.

In all, Time Warner reported a profit of $952 million, down from $971 million a year earlier. On a per-share basis, the company earned $1.20 a share, up from $1.16 and boosted by a lower share count. Excluding an impairment charge, among other items, per-share profit rose to $1.29 from $1.25.

From the Archives Hulu is planning a new service which will let subscribers stream feeds of major broadcast and cable-TV channels. It’s a move that would make Hulu a new competitor to digital streaming platforms and traditional cable-TV providers. Photo Hulu/Everett Collection (Originally published May 2, 2016

Revenue declined to $7 billion from $7.35 billion.

Analysts had expected adjusted earnings of $1.16 a share on $7.05 billion in sales, according to Thomson Reuters.

For the year, Time Warner now expects to post $5.35 to $5.45 in adjusted earnings per share, up from its earlier range of $5.30 to $5.40.

Time Warner shares were up 2.8% to $77.88 in recent trading.

Write to Shalini Ramachandran at shalini.ramachandran@wsj.com and Lisa Beilfuss at lisa.beilfuss@wsj.com