Carbon is the key ingredient for all life on our planet.
But how Earth acquired its "volatile elements" - which have low boiling points - such as carbon and sulphur remains a subject of some debate.
A team now argues that a collision between Earth and an embryonic planet like Mercury could provide the answer.
Details of the work appear in the journal Nature Geoscience.
"The challenge is to explain the origin of the volatile elements like carbon that remain outside the core in the mantle portion of our planet," said Rajdeep Dasgupta, a co-author of the study from Rice University in Houston, Texas.
According to a widely accepted idea called the Late Veneer Hypothesis, Earth formed from material that was largely devoid of volatiles. These elements, such as carbon, sulphur, nitrogen and hydrogen, were added later on by space rocks after Earth's core had finished forming.
"Any of those elements that fell to Earth in meteorites and comets more than about 100 million years after the Solar System formed could have avoided the intense heat of the magma ocean that covered Earth up to that point," said Yuan Li, from the Guangzhou Institute of Geochemistry at the Chinese Academy of Sciences.
"The problem with that idea is that while it can account for the abundance of many of these elements, there are no known meteorites that would produce the ratio of volatile elements in the silicate portion of our planet."
The group had previously published papers showing that if even if carbon had not vaporised into space when the planet was largely molten, it would have ended up in the metallic core of our planet - because the iron-rich alloys there have a strong affinity for carbon.
But if this is the case, where did the carbon in the mantle and biosphere come from?
The team used laboratory experiments that can recreate the high-pressure and high-temperature conditions that exist deep inside Earth and other rocky planets.
The found that one scenario that could reconcile the discrepancies in the carbon-to-sulphur ratio and carbon abundance was an embryonic planet like Mercury colliding with and being absorbed by Earth, early in its history.
"Because it's a massive body, the dynamics could work in a way that the core of that planet would go directly to the core of our planet, and the carbon-rich mantle would mix with Earth's mantle," said Dr Dasgupta.

There were about 19,000 diagnoses in 2015, compared to about 17,300 in 2006.
Public Health Wales (PHW) said the main reason for the increase was an ageing population.
The organisation's Dr Dyfed Wyn Huws said there was "good news" by way of significant reductions in smoking rates in recent decades.
There was a year-on-year decrease from about 19,800 cases in 2014, but the 2015 figure of 19,088 is likely to increase as statisticians revise the numbers.
Once age factors are taken into account, the rate decreased by more than 5% in men, but increased by more than 5% among women between 2006 and 2015.
This is partly due to the rate of lung cancer going down in men, but up among women. Historically, smoking rates peaked far earlier among men than women.
Breast, prostate, lung and bowel cancers remain the most common.
According to PHW, cases of liver, mouth, throat and melanoma skin cancer saw the biggest percentage increases.
The rates of stomach cancer and prostate cancer decreased, while mesothelioma rates increased by almost a third.
Dr Huws said: "We know that up to four in 10 of cancers in the population may be preventable.
"With an increasing number of cancer cases each year, cancer control is possible and important for future generations and for keeping rising health service demand in check.
"The good news is that we have seen significant reductions in smoking rates in recent decades.
"This is already bringing cancer rates down in men."
Much of Earth's life-giving carbon could have been delivered in a planetary collision about 4.4 billion years ago, a theory suggests.
[NEXT_CONCEPT]
The number of cancer cases in Wales has risen by almost 10% over a 10-year period.