Updated

Iranians smashed shop windows and set fire to a dozen gas stations in the capital Wednesday, angered by the sudden start of a fuel rationing system that threatens to further increase the unpopularity of President Mahmoud Ahmadinejad.

Police were sent to guard some stations after the violence, and there was calm during the day as motorists lined up to fill their tanks under the new restrictions.

The government had been warning for weeks that rationing was coming, but the announcement of its start just three hours before the plan took effect at midnight Tuesday startled people and sent them rushing to get one last fill-up.

The rationing is part of a government attempt to reduce the $10 billion it spends each year to import fuel that is then sold to Iranian drivers at less than cost, to keep prices low.

Iran is one of the world's biggest oil producers, but it doesn't have enough refineries, so it must import more than 50 percent of the gasoline its people use. The government says money saved from subsidies can go to building refineries, improving public transit and creating jobs.

But a hike in gas prices last month and now the rationing are feeding discontent with Ahmadinejad, who was elected in 2005 on a platform of helping the poor and fixing Iran's ailing economy. His failure to do so has sparked widespread criticism.

"This man, Ahmadinejad, has damaged all things. The timing of the rationing is just one case," said Reza Khorrami, a 27-year-old teacher who was among those lined up at one Tehran gas station late Tuesday.

Iranians are accustomed to gasoline at rock bottom prices. After a 25 percent hike in prices imposed May 21, gas sells at the equivalent of 38 cents a gallon.

But rationing will limit private drivers to only 26 gallons of fuel a month at the subsidized price. Taxis can get 211 gallons. Anything more than that will have to be bought at a higher price, which has yet to be announced.

The short notice of the plan's start appeared to be aimed at preventing a rush to hoard fuel. Still, long lines of cars, some up to a half mile, formed after the announcement, and the mood turned violent in places.

Drivers attacked some stations after managers stopped selling fuel before midnight, saying they had to recalibrate their pumps for rationing.

"This made people who were waiting in line angry, so they attacked the pumps," said a witness, Rasoul Enayati.

At one of the attacked stations, several pumps were partly burned and windows were shattered and desks damaged in the office.

Fire Department spokesman Behrouz Tashakkor said 12 stations in Tehran were set on fire. Iran's police chief, Gen. Ismail Ahmadi Moghaddam, put the total of damaged stations at 17, and said people also broke windows in cars and other buildings, including banks.

"The police have called out their forces to control any possible disorder after the implementation of rationing," Moghaddam said. State-run television said some of those involved in the violence had been detained, but did not specify how many.

During the day Wednesday, drivers were still lining up at stations, but in smaller numbers.

"I could not fill my car last night because of the rush. Now I have come to experience my first quota," said Hassan Riahi, a 21-year-old engineering student waiting at a service station guarded by four police officers.

Conservatives in Iran's parliament, especially those aligned with the country's national oil company, have long pushed for higher gasoline prices.

Still, Ahmadinejad resisted the idea because of his campaign promise to share Iran's oil wealth with the poor. The government first said May 21 that rationing would begin in two weeks, but the move was delayed without explanation.

Even before rationing, the president was targeted by growing criticism — even from conservatives who once supported him — for dramatically raising housing and food prices in the past year.

Many fear the boost in fuel costs will heat up already high inflation, which is reported running at nearly 14 percent a year by Iran's Central Bank but estimated at around 25 percent by economists.

Alaeddin Broujerdi, head of the parliamentary committee on national security and foreign policy, said there had been warnings of "security consequences" from starting rationing, but "not to the degree that occurred in Tehran" overnight.

"The rationing could have been implemented in a better way," he was quoted as saying by the Web site of Iran's state broadcasting company.

On Wednesday, a group of legislators tried to introduce a bill to cancel rationing, but failed to win majority support.

"People will get used to rationing soon," said Saeed Laylaz, a political analyst. "The country needs resources for reconstruction of its economy. It is no longer possible to import more than $10 billion of fuel a year."

Iran's government is seeking $12 billion in investments to boost refining capacity from 1.6 million barrels a day to 2.9 million barrels in the next five years. It also hopes to increase oil production to 5.3 million barrels a day by 2014, from the current 4.3 million.

Visit FOXNews.com's Iran Center for complete coverage.