The relatively conserved sequences of signal peptides and proregions that antimicrobial peptides (AMPs) contain have been successfully used to search for and identify novel AMPs from databases within the same lineages of fish and amphibians and across different animal classes. If such an approach is applicable to invertebrate species such as oyster has not yet been tested so far. In this study, we found a cDNA from the digestive gland of the oyster Magallana gigas, designated Mgdefdg, which contains two exons interspaced by one intron. Mgdefdg coded for a protein with features characteristic of defensins. The mature peptide had the cysteine-stabilized α-helix/β-sheet motif (CSαβ) and the consensus pattern C-X5-6-C-X3-C-X4-6-C-X3-4-C-X7-8-C-X-C-X2-C forming potential disulfide linkages C1-C5, C2-C6, C3-C7 and C4-C8 in the predicted tertiary structure. Functional assays revealed that recombinant mature MgDefdg (rmMgDefdg) was able to kill the Gram-negative bacterium Aeromonas hydrophila and the Gram-positive bacterium Staphylococcus aureus, and to induce bacterial membrane/cytoplasmic damage. ELISA showed that rmMgDefdg had high affinity to both A. hydrophila and S. aureus as well as the microbe-associated molecular pattern molecules LPS and LTA. Moreover, rmMgDefdg was capable of causing bacterial membrane permeabilization and depolarization, and intracellular ROS increase. Additionally, rmMgDefdg was not cytotoxic to human red blood cells and murine RAW264.7 cells. Taken together, our results indicate that MgDefdg is a previously uncharacterized defensin with membrane selectivity towards bacterial cells. It also shows that the use of conserved sequences of signal peptides of defensins can be an effective tool to identify potential defensins across different animal genera in invertebrates.