Gas prices are set by three things: And it's a little complicate, but if you wnat a quick course on it, here goes. Gasoline prices in the U.S. are determined by:
1) what the going rate is on the international market (the U.S. exports 50% of it's refined gasline to the top bidder, so if the price is high in Europe, the price is driven up here as supplies rung short),
2) the amount of refineries running in the U.S. that convert raw oil to gasoline at a given moment (a political decision can be made to cut some out for repair before an election to rig the election when gas prices sky rocket), and
3) speculation by oil traders who buycontracts on future oil according to what they speculate the price with be (When Congress rages against Iran because a billionaire, Super political action committee $30-billion-dollar donor demands it, speculation on future oil contract prices go up.)
There is an urban myth that the U.S. is not drilling for enough oil and that has caused prices of gas to go up. The U.S. has the most rigs running that it ever has had and is pumping more oil out of the ground than it has in 15 year. It is also exporting lots of gas.
All these things can be manipulated, and when they are speculators make litterally billions of dollars. It's said that David Koch makes 15 cents on every gallon sold in the U.S. because of his brilliant tallent for speculation on oil future contracts.
OK, now the illegally part of your question. Groups of speculators and producers work to make the most money they can out of producing and selling gas. The courts generally rule in favor of these people even when they bilk the public. There law seems to say that only if a large group of refiners are caught setting the price above nromal market prices, they are breaking the law. That is hard to prove but done all the time. The entire indurstry really is run by a few monoplies that generally work together to get the high dollar.