Amazon. com Inc. is buying an operator of primary-care clinics, a significant expansion of a similar service the tech giant launched several years ago that underscores its sweeping ambitions in healthcare.

The $3.9 billion deal, including debt, for 1LifeHealthcare Inc., which operates a primary-care practice under the name One Medical, is the first major acquisition announced during the tenure of Chief Executive Andy Jassy, for whom expansion into healthcare is a top priority.

Amazon will gain access to a practice that operates more than 180 medical offices in 25 U.S. markets and works with more than 8,000 companies to provide health benefits to employees, including with in-person and virtual care. That adds significantly to a smaller service Amazon launched in 2019 and for which it had signed up a limited number of employers in the last year.

“We think healthcare is high on the list of experiences that need reinvention,” said Neil Lindsay, senior vice president of Amazon Health Services. “We see lots of opportunity to both improve the quality of the experience and give people back valuable time in their days.”

The deal adds momentum to the push by technology and retail giants to make inroads into the nation’s $4 trillion healthcare economy. That push, along with new technology and medical discoveries, has fueled growth of medical care outside of hospitals and patients now more regularly seek care in more convenient and lower-cost settings. Demand for telehealth during the pandemic increased the use of virtual care.

Yet the healthcare industry, which is governed by state and federal regulations and an array of companies and providers operating in myriad ways, has proven notoriously difficult to disrupt. An earlier attempt to expand into healthcare, a joint venture set up by Amazon, Berkshire Hathaway Inc. and JPMorgan Chase & Co. called Haven, fizzled after three years. The three companies spent roughly $100 million but struggled to manage fundamental issues related to the cost of healthcare, data and staff turnover.

Once the deal closes, One Medical Chief Executive Amir Dan Rubin will remain as CEO of the business.

The deal price marks a roughly 77% premium, based on where shares of 1Life Healthcare closed on Wednesday. Based on a recently disclosed share count, the deal would be worth about $3.5 billion excluding debt.

Shares of 1Life Healthcare rose 68% to $17.10 on Thursday. Amazon shares rose slightly to $123.14.

Launched in 2019, Amazon Care expanded from a service offered to employees in Washington state to a health service with telemedicine components that the company is seeking to provide throughout the U.S. Amazon has said it has signed several agreements with companies to offer the service to their employees, in addition to its own workers.

Amazon’s goal is to be capable of providing a service that can begin with a chat in an app, continue with a virtual visit with a healthcare professional and even include a home visit within an hour after a user connects with the service. It could end with the delivery of prescription medication to a patient’s home, Amazon executives have said.

The tech company has also launched its own pharmacy business after buying online pharmacy PillPack Inc. about two years ago.

The most expansive version of Amazon Care isn’t yet available over all the U.S. The company said the telehealth component would be available nationwide last summer, and in-person care would be available in cities such as Washington, D.C., and Baltimore.

One Medical, a technology-based primary-care company, has sought to position itself as a convenient and flexible option for patients and for employers who offer healthcare benefits to workers.

The San Francisco-based company’s concierge-like model offers members virtual medical visits, wellness coaching apps and in-person visits and plans to expand its geographic reach this year, according to company filings.

It faced a Congressional investigation last year into its handling of Covid-19 vaccine distribution that concluded the company used “its access to scarce coronavirus vaccines to promote the company’s business interests and push vaccine seekers toward paying for One Medical memberships,” and that One Medical employees prioritized immunization for relatives and friends.

As part of the deal, the private-equity firm Carlyle Group Inc., which made a minority investment of up to $350 million in One Medical in 2018, would exit its position in the company, according to a person familiar with the investment. The investment was made before 1Life Healthcare’s 2020 initial public offering.

Write to Will Feuer at will.feuer@wsj.com, Melanie Evans at Melanie.Evans@wsj.com and Sebastian Herrera at Sebastian.Herrera@wsj.com