EXCLUSIVE. John Mahoney, the beloved dad on “Frasier,” left behind millions of dollars … and TMZ’s learned t’s a long list of potential benefactors.

John’s friend, Bernard Dowling, filed legal docs in Cook County, Illinois to open a probate case for his estate.

According to docs, obtained by TMZ, John’s estate is worth north of $5 million, including around $300k worth of real estate.

T are also 38 relatives and friends listed as potential benefactors.

TMZ broke the story … John died in hospice care back in February.

As we first reported … the official causes of death included brain disease, lung cancer and seizures.

John played Kelsey Grammer’s cranky father, Martin Crane, for 11 seasons on the hit sitcom.