Erdogan, who is in the US to attend the UN General Assembly, also discussed potential cooperation between Musk's space exploration firm SpaceX and Turkiye's space programme.
Turkey has previously said it "does not recognise this illegitimate election which constitutes a violation of Azerbaijan's sovereignty and territorial integrity."
The two leaders met in Russia’s Black Sea resort of Sochi, where the Russian president has a residence. A lot is riding on the talks for the world food supply.
The deal had allowed nearly 33 million metric tons (36 million tons) of grain and other commodities to leave three Ukrainian ports safely despite Russia's war.
Turkey’s current account deficit reached record levels this year – $37.7 billion in the first five months — and Erdogan is hoping the oil- and gas-rich Gulf states will help plug the gap.
Over the course of the last year, the Black Sea Grain Initiative has enabled the export in cargo of more than 32 million tonnes of Ukrainian grain.
Turkey has been holding off its final approval to Sweden's NATO membership for a while.
The first woman to lead Turkey's central bank, she brags a stellar resume that includes diplomas from Princeton and Harvard.
Erdogan, 69, won a new five-year term in a runoff presidential race last week.
Erdogan, who has led Turkiye as prime minister or president for 20 years, prevailed in a runoff race last weekend despite the country's ongoing economic crisis.