We demonstrate that during inflammatory responses the nuclear factor kappa B (NF-κB) induces the synthesis of melatonin by macrophages and that macrophage-synthesized melatonin modulates the function of these professional phagocytes in an autocrine manner. Expression of a DsRed2 fluorescent reporter driven by regions of the aa-nat promoter, that encodes the key enzyme involved in melatonin synthesis (arylalkylamine-N-acetyltransferase), containing one or two upstream κB binding sites in RAW 264.7 macrophage cell lines was repressed when NF-κB activity was inhibited by blocking its nuclear translocation or its DNA binding activity or by silencing the transcription of the RelA or c-Rel NF-κB subunits. Therefore, transcription of aa-nat driven by NF-κB dimers containing RelA or c-Rel subunits mediates pathogen-associated molecular patterns (PAMPs) or pro-inflammatory cytokine-induced melatonin synthesis in macrophages. Furthermore, melatonin acts in an autocrine manner to potentiate macrophage phagocytic activity, whereas luzindole, a competitive antagonist of melatonin receptors, decreases macrophage phagocytic activity. The opposing functions of NF-κB in the modulation of AA-NAT expression in pinealocytes and macrophages may represent the key mechanism for the switch in the source of melatonin from the pineal gland to immune-competent cells during the development of an inflammatory response.