A former Walmart Supercenter now being used as a migrant children's shelter is pictured on June 18, 2018 in Brownsville, Texas.

Walmart said it was "surprised and deeply disturbed" to learn that one of its former Texas stores was being used to house migrant children who had been separated from their parents. "We sold the building in 2016 to a developer and had no knowledge then of its intended use today," the giant retailer said in a Twitter post last week.

But real estate records pointed to the potential use. A Walmart executive signed a document that indicated the buyer was purchasing the property with a $4.5 million loan from a nonprofit that runs migrant children shelters.

The nonprofit, Southwest Key Programs, now leases the roughly 200,000-square-foot building in Brownsville, Tex., that houses nearly 1,500 migrant children, many of whom have crossed the border seeking refuge alone or with their families.

Read more from The New York Times:

A Macy's goes from mall mainstay to homeless shelter

Walmart says it will pay for its workers to earn college degrees

Walmart's Online Sales Grew by 33 Percent Amid Aggressive E-Commerce Push

When Walmart sold the building, Southwest Key was relatively unknown, even though for decades it had been running shelters for migrant children, as well as a juvenile justice program. The shelters have only recently provoked intense criticism after they began housing increasing numbers of children who had been separated from their parents as part of an aggressive crackdown on illegal immigration by President Trump.

[Read more about the former Walmart that is now a shelter for migrant children.]

A Walmart spokesman, Greg Hitt, acknowledged that the company had been aware that Southwest Key was financing the purchase as the deal was closing in December 2016. But he said the retailer had not looked into what the nonprofit did or why it was providing a loan to the buyer.

Commercial real estate lawyers say Walmart was following industry practice. Sellers in commercial property deals typically do not look deeply into a lender's background, but instead focus their due diligence on the buyer.

"This is a tragedy that children are being separated from their parents," Walmart said in a statement. "As we have said, when the property was sold to a developer more than a year ago, we did not know it would be used for what's happening today. Any attempt to suggest otherwise is outrageous."

The Brownsville supercenter was one of several stores that Walmart closed at the start of 2016 because they were either struggling or in underperforming markets.

By that August, Walmart was negotiating with Chacbak, a Texas real estate developer, over the sale of the property. Walmart said that, at that time, the developer was considering using the store as a call center or a warehouse.

As part of the sales agreement, Walmart made a long list of what the building could not be used for — mostly to thwart rivals and prevent adult or alcohol-related businesses from moving into the space.

The developer could not convert the property into a grocery store or a discount department store that might compete with Walmart. Also banned: a billiards parlor, slot machines and video stores selling NC-17 films.

There also could be no nude or "bathing suit-clad" models or dancers in the former store, according to real estate documents.

The deed did offer some potential uses, exceptions to the restrictions that included an "emergency care center, urgent or non-urgent medical service provider, or flea market."

The Walmart spokesman said the company "reasonably assumed what was laid out in exceptions is what the property would be used for."

The nonprofit had previously worked with one of the executives now associated with Chacbak. In 2012, the executive bought a nearby hospital, which was turned into a shelter for migrant children by Southwest Key, according to The Brownsville Herald, a local paper.

Executives at Chacbak, the developer, did not return phone calls seeking comment.

Jeff Eller, a spokesman for Southwest Key, said the nonprofit had agreed to finance the purchase because it could provide the money faster than a bank. At the time, Southwest Key was under pressure to increase its shelter capacity. Chacbak has already paid back the loan in full, he said.

The United Food and Commercial Workers, a union pushing for change at Walmart, was organizing events with Latino workers and activist groups in San Diego, Dallas and Chicago on Wednesday to protest the use of the former supercenter as a shelter for children separated from their families.

"The chances that Walmart — the largest retailer in the world, with billions of dollars of resources and entire legal and real estate departments at their disposal — didn't know about the intended use of this building is impossible to believe," said Amy Ritter, a spokeswoman for the union.