A firm mattress may not necessarily be best for a bad back, says a new study that challenges the popular belief.

The Spanish study found that mattresses of medium firmness were more effective than very firm ones in alleviating lower back pain.

While most doctors recommend hard mattresses for patients with lower back pain, there hasn't been a lot of research on the topic.

Scientists at clinics in three areas in Spain recruited 313 people who had unexplained chronic back pain while lying in bed or getting up in the morning.

Half of them were given a firm mattress, rated 2.3 on a European scale of mattress firmness, and half were giving a medium mattress, rated 5.6.

Before being given new mattresses, patients were asked to rate their back pain on a scale of one to 10 when were lying in bed and when they woke in the morning. After three months, they were asked for an update.

Overall, people who used the medium mattresses were more likely to report that the pain had subsided.

About 82 per cent of patients on medium mattresses said their conditions had improved, compared to 68 per cent of those on firm mattresses.

Some patients in both groups said their pain got worse over the course of the study.

The researchers admitted that the results were probably distorted because the patients could tell whether they were on a firm or medium mattress.

Correcting for that bias, the report suggested that people on medium mattresses were twice as likely to report improvement as people on firm mattresses.