Musk on Tuesday said Trump had asked him to return the two astronauts "as soon as possible," suggesting a change to NASA's current plan for a late March return.
"We will do so," Musk said.
"I have just asked Elon Musk and @SpaceX to 'go get' the 2 brave astronauts who have been virtually abandoned in space by the Biden Administration," Trump wrote on Truth Social.
"They have been waiting for many months on @Space Station. Elon will soon be on his way. Hopefully, all will be safe. Good luck Elon!!!"
His demand that SpaceX retrieve veteran NASA astronauts Butch Wilmore and Suni Williams, who have been assigned a SpaceX ride home since August, was an unusual intervention by a US president into NASA's operations that caught many agency officials by surprise, two officials said.
A NASA spokesman did not immediately return requests for comment.
Wilmore and Williams flew Boeing's Starliner spacecraft to the ISS last summer for an eight-day test mission that instead has lasted nearly a year because of problems with the craft's propulsion system.
NASA in August, during Joe Biden's administration, deemed Starliner too risky to bring them back to Earth and tapped SpaceX to return them on a Crew Dragon spacecraft.
That craft is already docked with the space station, having flown there for NASA's Crew-9 astronaut rotation mission in September with empty seats for Wilmore and Williams.
The astronauts' original February departure date on Crew-9 was delayed to late March because SpaceX needed more time "to complete processing" of a new Crew Dragon capsule that will replace theirs for the Crew-10 mission, NASA said in December.
The agency has a delicately co-ordinated ISS schedule, and an early return might leave the station's US contingent understaffed.
It was unclear whether Trump's demand would mean NASA bringing Crew-9 back to Earth before the Crew-10 capsule arrives, or SpaceX launching Crew-10 earlier than planned.