The measure, which passed on a 35-21 vote, goes to Gov. Pat Quinn for approval. It was passed by the Illinois House in April.
The bill restricts the use of marijuana in the presence of minors, in vehicles and in public, especially near school grounds.
State Sen. Bill Haine, D-Alton, the measure's Senate sponsor, said the program requires a doctor's written certification, registered patient photo identification cards and an electronic verification system.
"I am glad my colleagues understand that this program alleviates suffering and provides strong safeguards against abuse," Haine said in a statement. "Patients afflicted by the most unbearable conditions will soon have a compassionate answer to their cries for help."