Oil Minister Javad Owji told state television: "Some gas stations across the country suffered cyber attacks and fuel deliveries were stopped." Owji blamed the attack on external forces, saying they were trying to cause trouble as "the Zionist enemy (Israel) and the United States were hit in other ways."
Deputy Oil Minister Jalil Salari earlier said there was a problem with the cards Iranians use to buy subsidized gasoline.
Iran is a major oil producer and its gasoline prices are among the cheapest in the world. The card allows Iranians to buy up to 60 liters of gasoline per month at a subsidy rate of 15,000 rials (about 3 cents) per liter.
Salari said that after the system failure, the gas station "disconnected the online system" and fuel was being supplied offline.
Monday's chaos resulted in long queues of cars outside some Tehran stations, while others were completely closed, AFP reporters reported.
Iranian President Ibrahim Raisi called for an investigation and urged "immediate steps" to resolve the crisis.
Authorities set up a "crisis committee" and Salari said he hoped the system could be repaired within hours.
Iran suffered a similar week-long disruption in October 2021, which officials blamed on an unprecedented cyberattack by outside actors.
Fuel cards for Iranians were first introduced in 2007 in an effort to reform the subsidy system and curb large-scale smuggling.
Iran's economy has been hit by internal mismanagement and external pressure. In 2018, the United States withdrew from a landmark nuclear deal and reimposed sanctions that had been lifted for several years.
The government blames arch-enemy Israel for a wave of sabotage attacks and assassinations targeting its nuclear program.
The United States and Israel accuse Iran of planning attacks against allied forces and ships in the region.