The incident occurred after officers responded to the gas station in the 4300 block of East Ontario Mills Parkway around 10:45 p.m. Thursday, according to the Ontario Police Department.
Authorities said the man had been threatening customers and a clerk with the knife, and was demanding money.
Responding officers opened fire after the suspect charged at police, police said.
No officers or customers were injured. The suspect was pronounced dead at the scene.