Walgreens will open primary care doctors' offices in some of its Houston stores through a partnership with VillageMD, the companies announced Wednesday.

VillageMD will operate primary care clinics in five Walgreens stores, working with social workers, nurses and Walgreens' pharmacists. The 2,500-square-foot offices will be inside the Walgreens stores, though they will have a separate storefront and a door connecting the two spaces.

These clinics differ from Walgreens' existing walk-in clinics, which typically treat people for acute conditions like cough and flu. They are primary care doctors' offices where people can go for their annual physical and any other ailment they would normally see their doctor for.

"Patients are looking for primary care, and it's something our system is really in need of is more access to high-quality primary care," said Dr. Patrick Carroll, Walgreens' chief medical officer.

For more on investing in health-care innovation, click here to join CNBC at our Healthy Returns Summit in New York City on May 21.

Walgreens will shrink the stores' retail space to make room for the offices. The company declined to say which products it will remove. The locations will include six to eight exam rooms, as well as a waiting area, Carroll said. The first locations of the concept, called "Village Medical at Walgreens," are slated to open by the end of the year.

"What the Village Medical at Walgreens is going to offer is really high-quality primary care that can both improve quality and reduce costs at very convenient locations with a huge benefit quite honestly of that pharmacy support to work on adherence [to prescription drugs]," Carroll said.

Walgreens in recent years has signed a number of partnerships to bring more health services in its stores. It operates senior health centers with Humana, urgent care centers with UnitedHealth Group, dental clinics with Aspen Dental and diagnostic testing with LabCorp, among others.

Both Walgreens and CVS are trying to figure out how best use store locations, where sales of traditional drugstore products like candy and greeting cards are struggling. Offering teeth straighteners, nutritionists and doctors are some of the experiments they're currently testing.

Part of CVS' pitch for acquiring health insurer Aetna last year was the idea the combined company could provide better care and make people healthier. CVS opened its new health-focused concept stores, called "HealthHUBs" in Houston earlier this year. They include services to help customers manage chronic conditions like diabetes, hypertension and asthma.

Carroll said it's a coincidence that both companies are testing new formats in Houston and that Walgreens has been eyeing the market for some time. He said Walgreens is exploring whether to expand the VillageMD test to other markets.

Correction: The clinics will be located inside Walgreens' pharmacies with separate entrances outside. The company originally said the clinics would be "next to" the drug store.