US President Donald Trump -- seen here with India's Prime Minister Narendra Modi during a G20 summit meeting in Buenos Aires in November 2018 -- has mocked the Indian leader's contributions to a library in Afghanistan

US President Donald Trump on Wednesday mocked Indian Prime Minister Narendra Modi for funding a library in Afghanistan, suggesting it was of no use.

Trump brought up India's aid during a rambling press appearance at a cabinet meeting as he defended his push for the United States to invest less overseas.

While stating that he got along with Modi, Trump said the Indian leader was "constantly telling me he built a library in Afghanistan."

"You know what that is? That's like five hours of what we spend," Trump said.

"And we're supposed to say, 'Oh, thank you for the library.' I don't know who's using it in Afghanistan," Trump said.

It was unclear to which project Trump was referring, but India has committed $3 billion in assistance to Afghanistan since US-led forces toppled the extremist Taliban regime after the September 11, 2001 attacks.

Projects have included the reconstruction of an elite high school in Kabul and scholarships to India for 1,000 Afghan students each year.

Inaugurating the Afghan parliament building in 2015 after reconstruction financed by India, Modi promised to promote programs "empowering Afghan youth with modern education and professional skills."

India has been one of the most enthusiastic countries over the US mission in Afghanistan, where the former Taliban regime sheltered fiercely anti-Indian militants.

But India's role has alarmed its arch-rival Pakistan, whose intelligence service's continued ties to extremists in Afghanistan has been seen by analysts in part as a way to counter New Delhi.

Trump last month moved to pull all 2,000 US troops out of Syria and cut by half the 14,000-strong force in Afghanistan, calling for less spending overseas.

Alluding in Wednesday's remarks to the 1979-1989 Soviet occupation of Afghanistan, Trump said: "Russia used to be the Soviet Union. Afghanistan made it Russia because they went bankrupt fighting in Afghanistan."