Men who took up running and stuck with it had more "healthy swimmers", according to the research in the journal Reproduction.
The boost was only temporary, and began to wane within a month if the men stopped their treadmill training.
Experts say it is important to strike the right balance because too much exercise can harm sperm production.
Studies have shown that participation in competitive sports, like cycling, can lower sperm quality.
Keep your testicles cool - avoid tight underwear and hot baths
Avoid sexually transmitted infections
Cut down on alcohol
Get some exercise, but not too much!
All of the 261 men enrolled in the recent trial were healthy and did not have any fertility problems as far as they could tell. They had normal sperm counts and healthy-looking sperm and led fairly sedentary lives.
The men were allocated to one of four programmes:
- no exercise
- three sessions a week of high intensity interval training (10 one-minute bursts of very fast running with a short recovery period between each bout)
- three sessions a week of moderate exercise (30 minutes on a treadmill)
- three sessions a week of intense exercise (about an hour on a treadmill)
Exercise training appeared to boost sperm quantity and quality, with moderate exercise coming top.
Men in all three exercise groups lost weight and saw improvements in their sperm test results compared with the men who did no exercise over the 24-week trial period.
The researchers say at least part of the benefit may come from shedding excess weight - all three exercise groups lost some body fat.
Experts already know obesity can lower a man's fertility. A third of the men in each study group were overweight.
What is not clear is whether the boost from exercise translates to better fertility. That is something the researchers plan to explore in the lab by checking if training-induced changes affect the fertilising potential of sperm.
Lead researcher Behzad Hajizadeh Maleki said: "Our results show that doing exercise can be a simple, cheap and effective strategy for improving sperm quality in sedentary men.
"However, it's important to acknowledge that the reason some men can't have children isn't just based on their sperm count. Male infertility problems can be complex and changing lifestyles might not solve these cases easily."
Allan Pacey, professor of andrology at the University of Sheffield and spokesman for the British Fertility Society, said: "We have a very poor understanding of how physical exercise affects male fertility and sperm quality, but it is a question commonly asked by men wishing to improve their chances of having a child."
He said there probably was a level of exercise that is optimum for male fertility, but recommended that men check with their GP before embarking on anything too strenuous.
UK guidelines recommend that adults do at least 150 minutes of moderate aerobic activity, such as cycling or fast walking, or 75 minutes of vigorous aerobic activity, such as running, every week.