In the years leading up to his presidential bid, Donald Trump’s charitable foundation donated generously to several conservative nonprofits that would later help raise his stature within the movement.

The foundation, which Trump initially financed with his own money but has been funded by outside donors since 2008, gave more than $321,000 to prominent conservative groups that were important players on the road to the GOP nomination, according to tax filings first reported by RealClearPolitics. The groups included Iowa’s Family Leader, South Carolina Palmetto Family Council, the American Conservatives Union and Citizens United.

Together, the donations paint a picture of the wealthy businessman using charity-earmarked money to build relationships with conservative activists in early voting states. There are laws prohibiting self-dealing that would bar these kinds of donations if they were solely for Trump’s personal benefit, but there’s nothing stopping Trump from donating to these groups as a charitable act — even if it does grease the wheels of his presidential bid along the way.

Related: What We Know About the Trump Foundation Controversies

The donations are the latest window into a foundation that is already being investigated for possible wrongdoing: The New York Attorney general sent a cease-and-desist letter to the foundation last week, saying it didn’t have the proper certification to solicit donations in the state. Trump has previously come under fire fornot making the donations he boasted about, and purchasing pricey items with money from the charity. The foundation has also donated generously to children’s charities, like Operation Smile, and New York City nonprofits, like the Metropolitan Museum of Art and Hospital for Special Surgery.

One donation could have violated IRS laws if it hadn’t been later corrected: In 2013, the foundation contributed $10,000 to the political arm and 501(c)(4) of The Family Leader, instead of to The Family Leader Foundation, a charitable 501(c)(3) group. Neither the Family Leader nor the Trump campaign would comment on the donation, but a Trump Foundation donation the next year was directed towards the charitable arm.

Earlier this year, the foundation was cited for giving Florida Attorney General Pam Bondi’s reelection campaign a $25,000 donation in 2013 while she was investigating Trump University. It is illegal to give charitable funds to a political campaign, and the Trump foundation was fined $2,500 for it. Bondi later spoke at Trump’s nominating convention.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Related: Trump: 'I Hope' Trump Foundation Hasn't Broken Any Laws

Oran Smith, president of the Palmetto Family Council in South Carolina, told NBC News he had no idea at the time the donation he received in 2011 was from Trump’s foundation, rather than the businessman himself. Trump had flirted with a possible run for president in 2012.

It felt like the natural step in the “beginning of a friendship” between the two, Smith said, adding there had been no hint of quid pro quo.

Smith told NBC News that Trump invited him to a meeting at Trump Tower after he was quoted criticizing the real estate mogul in the press. Smith solicited a donation at the time, because "if you’re meeting with Donald Trump and you don’t ask for money, you’re out of your mind," he said. He later received a $10,000 check from Trump’s foundation.

“He never seemed to try and call in a favor, never seemed to try and ask me to organize,” Smith said. Four years later, in 2016, Trump was invited to speak at a Palmetto Family Council sponsored event just before the state’s primary, but couldn’t attend.

While these friendships did not all pan out politically for Trump — Smith has continued to criticize the candidate, and Family Leader’s Bob Vander Plaats endorsed rival Ted Cruz before the Iowa caucuses this year — the relationships did appear to be part of Trump’s overall effort to boost his political profile. Several donations coincided with speaking engagements that put Trump in front of the very early-voting state activists that he would need to impress if he ran.

The Trump campaign did not return a request for comment.

In 2013, the same year as his foundation’s first donation to Iowa’s Family Leader, Vander Plaats invited Trump to speak at the group’s leadership summit, according to the mogul. Trump spoke at the American Conservative Union’s Conservative Political Action Convention the year he gave the group $50,000, and said he was asked to speak at the Economic Club of Washington at an event the same year he donated there, too.

Though Evangelical Rev. Franklin Graham is not endorsing a candidate, he was an early ally of Trump — and his charities reaped the benefits, too.

Related: Trump a Brilliant Businessman? Tax Experts Say Otherwise

“The more you listen to him, the more you say to yourself, ‘You know, maybe the guy’s right,’” Graham told ABC News in 2011.

The organization named for his father, the Billy Graham Evangelical Association, got a $100,000 check a year later in 2012, while Samaritan’s Purse, a Christian relief group, got $25,000 the same year, and $10,000 the next year.

Trump and Graham would later come together on the campaign trail, with the latter helping to shore up evangelical support at a pastors' meeting earlier this year, and while touring Louisiana with Samaritan's after devastating flooding wrecked havoc on the state.

“I appreciate very much Donald Trump and Mike Pence coming down," Graham said. "That put a spotlight … on the suffering of these people."

Additional reporting by Liz Johnstone.

Update: An earlier version of this story said that Bob Vander Plaats had embraced Trump. He has met with the nominee, but he has not publicly stated his support.