Eating lots of pasta and rice was associated with reaching menopause one-and-a-half years earlier than the average age of women in the UK of 51.
However, the University of Leeds study of 914 UK women, also found that a diet rich in oily fish and peas and beans may delay natural menopause.
But experts say many other factors, including genes, influence timing of the menopause.
It's not clear how big a contribution dietary choices might make and women should not worry about changing what they eat based on the findings, they add.
Food findings
The research was published in the Journal of Epidemiology & Community Health and the women were asked what their typical diet contained.
A diet high in legumes, which includes peas, beans, lentils and chickpeas, delayed menopause by one-and-a-half years, on average.
Eating lots of refined carbs, particularly rice and pasta, was linked to menopause coming earlier by one-and-a-half years.
The researchers took into account other potentially influencing factors, such as a woman's weight, reproductive history and use of HRT, but they weren't able to consider genetic factors, which can influence age of menopause.
The study is observational and cannot prove any cause, but the researchers offer some possible explanations behind their findings.
For example, legumes contain antioxidants, which may preserve menstruation for longer.
Omega-3 fatty acids, which are in oily fish, also stimulate antioxidant capacity in the body.
Refined carbs boost the risk of insulin resistance, which can interfere with sex hormone activity and boost oestrogen levels. This might increase the number of menstrual cycles leading to the egg supply running out faster.
Health implications
Study co-author Janet Cade, professor of nutritional epidemiology, said the age at which menopause begins can have "serious health implications" for some women.
"A clear understanding of how diet affects the start of natural menopause will be very beneficial to those who may already be at risk or have a family history of certain complications related to menopause."
Women who go through the menopause early are at increased risk of osteoporosis and heart disease, while women who go through it late are at increased risk of breast, womb, and ovarian cancers.
Kathy Abernethy, menopause specialist nurse and chairwoman of the British Menopause Society, said: "This study doesn't prove a link with the foods mentioned, but certainly contributes to the limited knowledge we currently have on why some women go through menopause earlier than others."
Prof Saffron Whitehead, emeritus professor of endocrinology at St George's University of London and Society for Endocrinology member, said: "It is an interesting approach to investigate the timing of the menopause but I am not yet convinced that diet alone can account for the age of the onset of the menopause. There are too many other factors involved."
Dr Channa Jayasena, clinical senior lecturer and consultant in reproductive endocrinology and andrology at Imperial College, points out "the body's metabolism plays an important role regulating ovulation and having periods".
"It is tempting to speculate that this provides a recipe for delaying menopause. Unfortunately, a big limitation of these observational studies, is their inability to prove that dietary behaviour actually causes early menopause. Until we have that type of proof, I see no reason for people to change their diet."
More about: diet