A woman who was also rescued was treated at the hospital and released, Lt. Barry Heying said.
The pair left a dock on the Corte Madera Creek in the 14-foot motorboat around 10 p.m., Heying said.
The boat developed engine trouble in the Bay, Heying said. The man, who was not wearing a life vest, fell overboard while trying to restart the engine, Heying said.
When the man tried to get back in the vessel, it capsized, Heying said.
The man and the woman, who was wearing a life vest, were in the water for an unknown amount of time before they made it to the shore near the prison.
Prison guards in the tower saw the couple beckoning for help on the beach below the 6-foot retaining wall surrounding the prison at about 1 a.m., San Quentin State Prison Lt. E. Melton said.
The boaters were then hoisted over the wall, Melton said.
The man was unconscious and was being treated by paramedics when sheriff's deputies arrived, Heying said. He was pronounced dead at Marin General Hospital.
Deputies believe alcohol was a factor in the incident, and the man's death is being investigated by the county coroner's office, Heying said.
The San Rafael Fire Department also responded to the incident.