Sayyiduna Anas (may Allah be pleased with him) said: In the time of the Messenger of Allah (peace and blessings be upon him), prices increased greatly, so the people said: O Messenger of Allah! Prices have risen, so fix prices for us. The Messenger of Allah (peace and blessings be upon him) said: "Allah, the Exalted, is the Creator, the Restrainer, the Expander (i.e., sometimes He withholds, sometimes He gives freely), and the One who sets prices. And I hope that when I meet Allah, none of you will have any claim against me regarding injustice in life or wealth."
That is, neither in life nor in wealth has any kind of injustice been committed by me in this matter; here, the Noble Prophet sallallahu alayhi wa sallam has, in effect, described price-fixing as an act of injustice and refused to do so.
In reality, during the era of ignorance (Jahiliyyah), it used to happen that when there was a rise in grain prices, shortsighted rulers would summon the traders, beat and punish them, and force them to sell grain at a fixed price. As a result, the traders would stop importing grain altogether, which would lead to scarcity and famine. For this reason, the Messenger of Allah sallallahu alayhi wa sallam strictly refused to fix prices.
Imposing controlled rates on grain prices, if the traders are not unjustly raising the rates, is an injustice and oppression against them.
It is stated in al-Hidayah: The ruler of the time should not fix prices; however, if the grain traders deliberately and without reason raise the prices excessively, then the judge (qadi), with the consultation of the people of opinion (ahl al-ra’y), may fix the prices.