When Elon Musk rolled out his plans for going to Mars, he stated SpaceX's intention to use In Situ Resource Utilization (ISRU) on the surface of Mars to manufacture propellants for the Starship's return voyage to Earth.
The first Starship to land on Mars will carry a small manufacturing plant to produce oxygen and methane propellants. How will that work?

Technology involved
The Jet Propulsion Laboratory has been researching methods of manufacturing propellants on Mars since the 1970s. In 1978, they published a paper in which they confirmed the viability of producing oxygen and methane from the resources available on Mars using the Sabatier reaction.
The ”Sabatier reaction” or ”Sabatier process” produces methane and water from a reaction of hydrogen with carbon dioxide at high temperatures and pressures in the presence of a nickel catalyst. It was discovered by the French chemists Paul Sabatier and Jean-Baptiste Senderens in 1897.

The Sabatier technology is being used on Earth today for production of synthetic natural gas, and is also in use at the International Space Station to recover water from exhaled carbon dioxide.
International Space Station
Oxygen generators on board the International Space Station produce oxygen from water using electrolysis; the hydrogen produced is discarded into space. This approach requires large amounts of water to be regularly transported to the space station for oxygen generation in addition to that used for human consumption, hygiene, and other uses.
In 2018, ESA's Advanced Closed Loop System (ACLS) was installed in the ISS.
ACLS recovers water from exhaled carbon dioxide – it does this by using the Sabatier reaction to process the carbon dioxide and the hydrogen previously discarded from electrolysis. The process produces water and methane. The methane is released into space. The water is returned to the ISS environmental system.

Half of the hydrogen processed by the system becomes wasted as methane. Consequently, a small amount of hydrogen is supplied from Earth to make up the difference. The system has reduced the amount of water that needs to be regularly transported to the ISS by 400 L per year.
Producing oxygen and methane on Mars
NASA has confirmed through Mars space probes that Mars contains carbon dioxide and water which are necessary for the Sabatier reaction to produce oxygen and methane. NASA is actively working on developing new technologies to support production of oxygen and methane on Mars.
An overview of NASA plans are provided in the following presentation.










NASA/JPL MOXIE experiment on Mars
NASA/JPL currently has the Mars Oxygen ISRU Experiment (MOXIE) on Mars. The experiment is part of the Perseverance Mars rover. MOXIE's purpose is to demonstrate the feasibility of producing propellant grade oxygen on Mars.

On April 20, 2021 the experiment successfully produced oxygen on Mars.
For more information on MOXIE, please see this article MOXIE – NASA/JPL's first attempt to generate propellant grade oxygen on Mars.
SpaceX rocket propellant manufacture plant
SpaceX has not provided any updates on their plans or progress related to the SpaceX propellant manufacturing plant to be used on Mars.