President Trump’s charitable foundation doled out $3 million in grants last year, mainly to veterans and military groups — though the incoming commander in chief did not give any of his own money, according to its latest tax filing, obtained by The Post.

The document shows that the Donald J. Trump Foundation added $2.9 million to its coffers with large checks written by Trump’s friends and $100,000 from his daughter Ivanka.

Neither Trump nor the Trump Organization donated to the charity last year, although Trump did write a $1 million personal check to the Marine Corps-Law Enforcement Society in Westchester County.

Billionaire Las Vegas casino mogul and Trump friend Phil Ruffin gave $1 million to the Trump Foundation. Ruffin once flew Trump to Russia on his private plane, he told Forbes in March. “We were having lunch with one of the oligarchs there. No business was discussed,” he said.

Another $1 million donor was Laura Perlmutter, the wife of Marvel Entertainment CEO Ike Perlmutter, also a pal of the president’s.

The Daryl & Steven Roth Foundation in New York contributed $50,000. Steven Roth heads Vornado Realty Trust and was picked to head a Trump infrastructure advisory council that never materialized.

John Cafaro, an Ohio shopping-mall developer who admitted violating federal law in 2009 by giving a secret loan to his daughter’s 2004 congressional campaign, gave $50,000.

The giving came during Trump’s presidential run and amidst controversy over how much the foundation, which Trump the New York real estate mogul started in the 1980s, collected and distributed.

Trump boycotted a candidates’ debate on Jan. 28, 2016, and instead held a fund-raiser for veterans in Iowa. Most of the money the foundation raised last year came in through that event, which took in $2.8 million.

After questions were raised about the funds, Trump eventually released a list of veterans groups that got the money, including the Green Beret Foundation, the Disabled American Veterans, the Veterans Airlift Command and Honoring America’s Warriors. Each group, also listed in the tax filing, got $100,000.

Veterans-in-Command in Queens, which is supposed to provide housing for vets, got $150,000 — money its director told The Post mainly went to pay off debts. After a Post exposé about the squalid living conditions it provided, the city issued vacate orders to two units with fire hazards.

The tax filing shows money went to other local nonprofits, including $100,000 to the September 11 memorial & Museum in lower Manhattan, $5,000 to the Central Park Conservancy, and $2,500 to the Lustgarten Cancer Foundation on Long Island.

The foundation gave $50,000 to the private Columbia Grammar and Preparatory School, which Trump’s son, Barron, attended.

Trump announced in December 2016 he was shuttering the foundation to avoid any potential conflict of interest as he assumed the presidency.

State Attorney General Eric Schneiderman had already opened a probe into the group and ordered it to cease fund-raising in New York because it had failed to file required registration papers.

Schneiderman’s office said last week that its investigation is ongoing, and that the foundation can’t legally dissolve until it is over.

Additional reporting by Susan Edelman