UnitedHealth Group Inc. will buy DaVita Inc.’s physician network business for $4.9 billion, adding hundreds of medical clinics to the biggest U.S. health insurer’s growing business of providing direct medical care.

The all-cash takeover will bulk up UnitedHealth’s front-line business called OptumCare, allowing it to take more control over how its insurance dollars are spent. The deal comes less than a week after CVS Health Corp. agreed to buy insurer Aetna Inc. for $67.5 billion, which will team the insurance company with CVS’s pharmacies and in-store clinics.

“Combining DaVita Medical Group and Optum advances our shared goal of supporting physicians in delivering exceptional patient care in innovative and efficient ways,” Larry Renfro, CEO of Optum, said in a statement.

Michael Wiederhorn, an analyst at Oppenheimer, said the deal makes sense.

“We continue to favor the methodical approach to building a consumer-oriented, vertically integrated healthcare company piece by piece, as opposed to AET’s move to be acquired by CVS,” he said in a research note. UnitedHealth “will be better positioned to lower costs by keeping its beneficiaries out of the hospital, while gaining valuable information that will help it better manage their health.”

Late last month, UnitedHealth said it planned to keep expanding Optum’s physician business by adding new markets and doctors. Less than a year ago, the company acquired the surgery-center chain Surgical Care Affiliates, adding outpatient procedures to its offerings.

DaVita Medical manages physician groups in California, Colorado, Florida, Nevada, New Mexico and Washington, and sees about 1.7 million patients a year at its 300 clinics, 35 urgent-care centers and six outpatient surgery sites, according to the company.

The sale represents a retreat for the Denver-based company, whose main business is treating kidney patients at dialysis centers.

In 2012, DaVita bought HealthCare Partners for $4.42 billion as part of an effort to expand into broader medical services. At the time, DaVita CEO Kent Thiry called it a chance to expand on “where the puck is headed for American health care and to establish a really massive additional avenue for future growth.” Then, in 2016, DaVita acquired the Everett Clinic, another physician group, for about $385 million.

DaVita said it plans to use the funds from the sale to repurchase shares over one to two years after the deal is completed in 2018, and to repay debt. The company’s biggest holder is Warren Buffett’s Berkshire Hathaway Inc., which owned 21 percent of the shares as of Sept. 30, according to data compiled by Bloomberg.

Joe Mello, chief operating officer of DaVita Medical Group, will continue in a leadership role under Optum, the companies said in the statement.

Peter Grauer, the chairman of Bloomberg LP, the parent company of Bloomberg News, is a member of DaVita’s board.