Proposition 203 was ahead by 4,421 votes out of more than 1.63 million votes counted. The measure started out losing by about 7,200 votes on Nov. 2 and the gap gradually narrowed in the following 10 days.
Only about 10,000 early and provisional ballots remain to be counted in the state, and all are in Maricopa County.
Marijuana Nation: The New War Over Weed
If the measure passes, Arizona would be the 15th state with a medical marijuana law.
"We were optimistic that this is what the result was going to be today, and we're thrilled that it came to reality," said Andrew Myers, campaign manager for the Arizona Medical Marijuana Policy Project. "Moving forward it's our responsibility to help implement a program that Arizona can be proud of."
Opponents of the initiative, including all Arizona's sheriff's and county prosecutors, the governor, attorney general, and many other politicians, came out against the proposed law.
"All of the political leaders came out and warned Arizonans that this was going to have very dire effects on a number of levels," said Carolyn Short, chairwoman of Keep AZ Drug Free, the group that organized opposition to the initiative. "I don't think that all Arizonans have heard those dire predictions.
"Election night and this entire week has been a very exciting time for us - we just didn't know we had actually lost," Short said. "I am incredibly proud of our small but dedicated army of volunteers who worked very, very hard for months to educate voters about Prop 203."
Backers of Proposition 203 argued that thousands of patients faced "a terrible choice" of suffering with a serious or even terminal illness or going to the criminal market for pot. They collected more than 252,000 signatures to put the measure on the ballot - nearly 100,000 more than required.
The measure will allow patients with diseases including cancer, HIV/AIDS, Hepatitis C and any other "chronic or debilitating" disease that meets guidelines to buy more 2½ ounces of marijuana every two weeks or grow plants.
The patients must get a recommendation from their doctor and register with the Arizona Department of Health Services. The law also allows for no more than 124 marijuana dispensaries in the state.
"Our law is written to be incredibly restrictive. We're talking only about seriously or terminally ill patients," Myers said. "There are 14 medical marijuana states, and for political reasons they decided to narrow in on (problems in) California because they don't believe that marijuana is medicine at all."
The measure began Friday losing by about 1,500 votes.
The vast majority of outstanding votes were in Maricopa County, which includes Phoenix, on Friday morning. About 30,000 provisional ballots during the day, and those went heavily for medical marijuana backers. The county also processed 5,024 early ballots.
Maricopa County has 8,000 early and 2,000 provisional ballots still to count, and all other counties have finished their counts. Outstanding ballots will be counted through the weekend despite a state law that generally says all vote tallying must be completed by Friday.
Teams made up of members of the Republican and Democratic parties are overseeing elections workers tasked with reviewing the early ballot. Those ballots have some problem that prevents a vote-count machine from tallying them, typically because a voter used a marker to fill in the oval and it bled through to the other side or otherwise is unreadable.
The teams are examining the ballots, determining voter intent and filling out new ballots that the machine can read, Purcell said.