c.1300, from O.Fr. ma dame, lit. "my lady," from L. mea domina (cf. madonna). Meaning "female owner or manager of a brothel" is first attested 1871.
1599, see madam, which is an earlier borrowing of the same Fr. phrase. Originally a title of respect for a woman of rank, now given to any married woman. OED recommends madam as an Eng. title, madame in ref. to foreign women.