Pistacia integerrima leaf galls are used in several traditional medicines to cure many diseases such as diarrhea, asthma, fever, cough, vomiting, and hepatitis. The main goal of the present investigation was to assess the antidiarrheal effect of the Pistacia integerrima extracts/fractions and four isolated flavonoid compounds (1−4) on mice. An in vivo assay involving castor-oil-induced diarrhea was used to evaluate the antidiarrheal potential of extracts/fractions at 100, 200, and 400 mg/kg p.o., as well as isolated compounds at 5, 10, and 20 mg/kg p.o. Pretreatment of mice with extracts/fractions significantly attenuated castor-oil-induced diarrhea in a dose-dependent manner. Among all crude extracts and fractions, the ethyl acetate extract was the most effective with 100% protection against diarrhea followed by chloroform (75% protection) at 400 mg/kg p.o. Although all the isolated compounds exhibited strong antidiarrheal activity, isolated compounds 1 and 4 demonstrated 100% protection against diarrhea. Moreover, docking models were performed using the Molecular Operating Environment (MOE) and AutoDock software and suggested that the extracts and isolated compounds exert antidiarrheal activity by inhibiting mu-opioid and delta-opioid receptors. Therefore, our finding affords a strong pharmacological basis for the traditional use of P. integerrima galls in the treatment of diarrhea.