Before a gunman opened fire on the crowd Sunday and killed three people, the Gilroy Garlic Festival was known as a beloved Californian food event which raised millions of dollars for the local community.

Founded in 1979, the three-day food festival held in the tight-knit community of Gilroy, 30 miles southeast of San Jose, is a celebration of all things garlic and has been certified by Guinness World Records as the world’s largest garlic festival.

The festival attracts up to 100,000 people who consume a pungent two tons of locally-grown garlic across the three days.

Foodies chow down on garlic shrimp, garlic fries, garlic calamari — even garlic ice cream — while enjoying live music and garlic workshops. A garlic queen is also crowned to reign over the festivities.

Since its inception 41 years ago, the event has raised more than $11.7 million for local charities with the money going back to local schools, charities and non-profit organizations, according to organizers.

The event was founded by Dr. Rudolph Melone, who, according to his New York Times obituary, was inspired after reading about a similar event in France.

He presented the idea to the Rotary Club and enlisted local garlic growers in the town which produces 60 million pounds of it annually.

More than 4,000 volunteers received an hourly “stipend” paid to a charity of their choice, with the money flowing to more than 140 non-profit groups in the Gilroy and surrounding areas.

Billed as “the world’s greatest summer food festival,” this year’s event boasted a performance by Grammy winning singer Colbie Caillat and cooking demonstrations with celebrity chef Tom Colicchio.

Since 1979, 4.4 million people have attended the event.

On Monday, police sources identified local teen Santino William Legan, 19, as the gunman who opened fire on the crowd, killing three people — including a six-year-old boy — before being shot dead by police.

Another 15 people were injured in Sunday’s carnage.

In a statement, festival executive director Brian Bowie called the shooting, “one of the most tragic and sad things I have ever had to see.”

“Gilroy is an amazing, tightly-knit community. We are family,” Bowie wrote. “For over four decades that festival has been our annual family reunion.”

“It’s such a sad, just horribly upsetting circumstance that this happened on the third and final day of this year’s festival,” he added.