The uproar prompted the company, which is based in Lehi, Utah, and offers DNA testing to help people research their genetic roots, to issue an apology.

“Ancestry is committed to telling important stories from history,” Gina Spatafore, an Ancestry.com spokeswoman, wrote in an email. “This ad was intended to represent one of those stories. We very much appreciate the feedback we have received and apologize for any offense that the ad may have caused. We are in the process of pulling the ad from television and have removed it from YouTube.”

Ms. Spatafore declined to elaborate further. But, according to a report in The Salt Lake Tribune, the online ad was originally targeted at Ancestry.com’s Canadian audience. Many people who escaped slavery fled to Northern states or went farther, crossing the border into Canada. The journey, though, was perilous, with escaped slaves beaten or killed if they were captured. Some made their escape via the Underground Railroad, a network of people who offered shelter as slaves made their way north.

Sexual relations between white men and black women during that era often involved rape, given that Southern slave owners treated the women as property and the women had no power to protest advances. Women who had to acquiesce to their owners’ demands sometimes bore them children of mixed race. Most famously, Sally Hemings, an enslaved woman, had several children with Thomas Jefferson, the former president and a slave owner.