In 2021, Robert F. Kennedy Jr. earned more than $500,000 as the chairman and top lawyer at Children’s Health Defense, the nonprofit organization that he has helped build into a leading spreader of anti-vaccine falsehoods and a platform for launching his independent bid for the White House.

The compensation was almost three times as high as the amount paid to the organization’s president, but it was not Mr. Kennedy’s biggest source of income. Neither was his family’s fabled wealth. Instead, most of his earnings around the same time came from law firms — a total of $7 million for lending them his name, connections and expertise to sue major companies.

Throughout his long public life, Mr. Kennedy has cultivated an image as a man committed to a greater good, the blessing and burden of belonging to one of America’s most storied political families. Whether cleaning up rivers as an environmentalist or railing against the purported dangers of inoculations, he has said he is driven by his family’s legacy of civic duty and sacrifice.

He built his presidential run around similar themes, even as his cousin dismissed the campaign as a “vanity project” and other relatives disavowed his beliefs. On the trail, Mr. Kennedy has delivered a populist message of anti-corporate rhetoric and debunked science while invoking a powerful lineage: his uncles, former President John F. Kennedy and Senator Ted Kennedy, and his father, Senator Robert F. Kennedy.

“RFK Jr. began a career of public services as soon as he passed the NY State Bar,” reads one of the top lines on his campaign website.

In a 2018 book, he credited his mother, Ethel, for instilling important values. “She tried to give us the sense that we mustn’t be satisfied with ‘making a big pile for ourselves and whoever dies with the most stuff wins,’” Mr. Kennedy wrote. “Our lives, she taught us, should serve a higher purpose.”

But an examination of Mr. Kennedy’s finances by The New York Times, including public filings and almost two dozen interviews as well as tax returns and other documents not previously made public, showed that while he appears to believe in the causes he champions, they have also had a practical benefit: His crusades, backed by the power of his name, have earned him tens of millions of dollars.

Mr. Kennedy inherited many things from his family — a charismatic presence, a gift for public speaking, a place among the nation’s elite — but not necessarily the kind of money that would support a life of both altruism and the trappings of wealth he seems to enjoy, The Times found. His grandfather, Joseph P. Kennedy, poured a fortune into trust funds for his descendants, helping to support the political ambitions of his sons. But Mr. Kennedy came into a relatively modest portion.

Behind much of his public career has been a relentless private hustle: board positions and advisory gigs, side deals with law firms, book contracts and an exhausting schedule of paid speeches, once upward of 60 a year by his own count.

While most people have to work, Mr. Kennedy did not always settle for the six-figure salary he was earning in positions with nonprofits. For decades, he has entwined his loftier missions with opportunities for enrichment. In addition to his salary at Children’s Health Defense, for instance, he stands to profit personally from lawsuits, including against the pharmaceutical giant Merck over a common vaccine for children.

When Mr. Kennedy was still best known as an environmentalist, he met Alan Salzman, an investor in clean technology companies, and was intrigued: Mr. Kennedy wanted to find alternatives to carbon-based energy, “which I think is the biggest enemy to American democracy and the environment,” he said in a 2012 deposition reviewed by The Times.

“And I also saw it as an opportunity to make some money for my family,” he continued.

Mr. Kennedy would earn millions of dollars over at least eight years from work connected to Mr. Salzman’s venture capital firm, VantagePoint, including promoting a project that other environmentalists opposed.

In an interview, Mr. Kennedy said that he was proud of giving his family a good life while promoting his causes.

“I have been able to use the various gifts I’ve been given — education, the contacts and the value of a name that a generation in my family put a lot of effort into enhancing and retaining its value,” he said. “I’m grateful that I’ve been given those gifts and that I am able to do well by doing good.”

His campaign said in a statement that he had “never put a need or desire to make money ahead of his values and moral compass.”

Recently, Mr. Kennedy’s presidential bid has gained some traction. In a poll conducted last month by The Times and Siena College, 24 percent of voters in battleground states said they would support Mr. Kennedy in a theoretical matchup between him, President Biden and former President Donald J. Trump, the leading Republican candidate.

In the campaign, Mr. Kennedy has cast himself as an heir to his family’s mystique. Yet what has at times looked from the outside like the glamorous life of a dynastic prince has occasionally been underwritten by others.

Wealthy friends were behind the purchase of the home Mr. Kennedy used on the family compound on Cape Cod, records show. He had an arrangement with a major environmental nonprofit group to pay for his children to accompany him on work trips, and he accepted a free Lexus as part of a promotional event for green vehicles.

“The Kennedys’ wealth is inextricably intertwined with people’s impression of the Kennedys — and that isn’t a surprise when you think their grandfather amassed one of America’s biggest fortunes when his kids were young,” said Fredrik Logevall, a historian at Harvard who is writing a two-volume biography of John F. Kennedy.

“But two generations later,” Professor Logevall said, “some family members have more of the money than others.”

Joseph Kennedy’s estate, widely believed to be valued at roughly $500 million when he died in 1969 (about $4.2 billion in today’s dollars), was left largely in trusts for his descendants.

Robert Kennedy had been assassinated the previous year while running for the Democratic nomination for president. He left half his estate to Ethel and divided the remainder equally among his children, according to documents filed in Manhattan Surrogate Court. But after an expensive campaign, he died with heavy debt, and more than half of his estate went to pay it off.

While the court documents put the senator’s total estate at $1.6 million, there was more, shrouded in trusts whose value is not public. Still, disclosure forms Mr. Kennedy filed with the Federal Election Commission as part of his bid for the presidency, as well as other documents, provide some insight into his portion of the family wealth.

Mr. Kennedy owns between $4 million and $15 million in inherited assets, held in trusts — the biggest, a stake in Wolf Point, a Chicago real estate development built on land his grandfather bought decades ago. Over the years, Mr. Kennedy has enjoyed large one-time distributions from his trust funds when assets were sold, according to bank records and public documents.

But the trusts do not tend to generate much steady income: He received between roughly $29,000 and $90,500 over a recent 18-month period, according to the F.E.C. filing. While certainly a boon, it is far from enough to finance Mr. Kennedy’s lifestyle: At one point, a little over a decade ago, he estimated that his annual household expenses were $1.4 million.

“I have never gotten a lot of money from my family,” Mr. Kennedy told The Times.

He said his biggest expense in recent years was his children’s education. He drives, he said, a 1998 minivan. But he also lives with his wife, the actress Cheryl Hines, in a $6 million home in Brentwood, an affluent Los Angeles neighborhood.

Mr. Kennedy said that one reason his branch of the family never enjoyed the clan’s presumed riches, in addition to his father’s debt, is that he was one of 11 children, leaving him with less inherited money than other members of his generation. (When his cousin John F. Kennedy Jr. died in 1999, he left a $250,000 bequest to Mr. Kennedy.)

In the 2012 deposition, which Mr. Kennedy gave during his bitter divorce from his second wife, Mary Richardson Kennedy, he said Ethel Kennedy was “broke,” and family members secretly helped cover her living expenses.

“Those of us who stay at her house pay her, and she doesn’t know she’s being paid,” he said.

In the interview with The Times, Mr. Kennedy said that his mother, now 95, is no longer struggling financially.

By the year 2000, after a bumpy early adulthood that included an arrest for heroin possession, Mr. Kennedy was a nationally recognized environmental lawyer. The previous year, he had been named a hero of the planet by Time magazine for his work with the Riverkeeper organization, among the groups credited with cleaning up New York’s polluted Hudson River.

As a lawyer, he was on the payrolls of both the environmental litigation clinic at Pace University’s law school and the Natural Resources Defense Council, where his salary was subsidized by Riverkeeper, according to a person familiar with the arrangement.

That year, Mr. Kennedy saw an opportunity that would eventually net him millions of dollars.

He co-founded a law firm, Kennedy & Madonna, with Kevin Madonna, a Pace Law graduate who had worked at the clinic. The firm allowed Mr. Kennedy to target polluters while profiting at a scale far beyond his nonprofit salaries. Kennedy & Madonna teamed up with other firms on class-action lawsuits against major corporations, including Dupont and the Southern California Gas Company, and took a cut of any proceeds.

Although Mr. Kennedy was listed first in the firm’s name, he said in his 2012 divorce case that his partner dealt with most of the detailed legal work. Mr. Kennedy typically handled depositions and court appearances — moments when his famous name and presence would have the strongest effect. Mr. Madonna declined to comment.

In 2002, Mr. Kennedy also forged a relationship with a personal-injury law firm in Pensacola, Fla. He was paid to do a radio show with one of the firm’s partners, and was listed as “of counsel” at the firm, which did some class-action environmental litigation.

It was adding up to a good living, by most standards. By 2008, his jobs at the Florida firm and the nonprofits were bringing in about $400,000 a year. His trust funds and investments connected to his grandfather generated at least $150,000, according to his tax return.

Income from Kennedy & Madonna could be bumpy. For instance, from 2008 through 2010, the firm produced virtually no income, tax records show. But in 2011 Mr. Kennedy received $700,000, part of the firm’s share of a legal settlement with Ford Motor.

Still, Mr. Kennedy was leading an expensive life between his home in Bedford, N.Y., a wealthy enclave north of Manhattan, where he lived with his wife and children, and the home he was using on Cape Cod. He bought the Bedford house in the 1980s, with financing from the sale of a luxury Manhattan apartment that a close family friend had willed to him, records show.

In 2010, Mr. Kennedy’s household expenses reached $1.4 million. The mortgage and a home-equity loan on the Bedford property cost about $191,000. Memberships to a yacht club and other organizations ran him more than $14,000, while nannies and housekeepers cost more than $70,000. Pool maintenance was upward of $12,000. On top of those expenses, his assistant earned roughly $200,000.

His use of the home at the Kennedy compound in Hyannis Port, Mass., was made possible by wealthy friends, The Times found. It had been purchased by a lawyer with ties to Wendy Abrams, a Chicago-based philanthropist who has donated millions of dollars to environmental causes, including some of Mr. Kennedy’s, records show.

In the interview, Mr. Kennedy said Ms. Abrams and her husband, whom he described as his closest friends, stepped in because he did not have enough money to buy the home when it came up for sale.

The house, a six-bedroom with traditional gray shingles, was bought in 2008 for $2.5 million. For years, Mr. Kennedy paid $4,000 a month in rent. The lease, which was reviewed by The Times, shows that he had an option to buy the home for the original purchase price, which he did in 2020.

The Abramses, Mr. Kennedy said in the deposition, had also footed the bill for a vacation to Jamaica for him; his then-girlfriend, Ms. Hines; and their respective children, while the Natural Resources Defense Council sometimes paid for his children to travel with him.

“All my vacations are paid for. So I just, I try not to spend money,” Mr. Kennedy said in the deposition.

Ms. Abrams told The Times she commonly hosted friends in rented vacation homes. Mr. Kennedy said in his interview with The Times that his work for the N.R.D.C. could involve spending weeks in other countries, and the nonprofit agreed to pay for his children to travel to see him. The N.R.D.C. declined to comment.

Mr. Kennedy also accepted a free Lexus from Toyota, The Times found. He said he received the car when he helped the automaker promote charging stations for electric vehicles in California.

In addition to his jobs with nonprofits and his law firms, Mr. Kennedy turned to paid speeches as a big source of income. He said he could charge as much as $250,000 for a talk overseas, and at least $25,000 for others.

By the time he entered into divorce proceedings with Ms. Richardson Kennedy, he was on the road at a frenetic pace, at one point giving more than 60 speeches a year. (Ms. Richardson Kennedy died by suicide in 2012, before the divorce was final.)

If he wasn’t around enough to put in a traditional workweek at any one organization, his name and natural charisma certainly raised their profiles and drew celebrities and deep-pocketed benefactors to their events, including the actors Pierce Brosnan, Alec Baldwin and Ms. Hines.

At the same time, Mr. Kennedy’s high-profile environmental work opened the door to a lucrative shadow career as a corporate director and consultant. His reputation, experience and wide network of contacts had value: He could make introductions, offer advice or help secure financing.

A turning point had come in 2005. Mr. Kennedy gave a speech at the home of Mr. Salzman, the managing partner of VantagePoint Capital Partners, then one of California’s most prominent venture capital firms. It was an early investor in Tesla, the electric carmaker, and was known for backing companies that were offering solutions to the planet’s environmental problems.

Mr. Salzman hired Mr. Kennedy in 2007, initially paying him $100,000 a year to consult on potential investments. He was obviously passionate about clean water, but also well-connected and very knowledgeable,” Mr. Salzman told The Times.

In 2009 Mr. Kennedy became a partner, earning $340,000 at VantagePoint, in addition to his other sources of income. Two years later his salary had jumped to more than $750,000, records show.

Mr. Kennedy’s position at VantagePoint led to other paying gigs at companies in which the fund had invested. For instance, he took in $80,000 a year from BrightSource, a developer of large-scale solar plants.

That work put him in conflict with environmentalists over two projects BrightSource was planning in California. The first was set for the Ivanpah Valley, in the desert near Nevada. A number of environmental groups opposed the idea, saying it threatened desert tortoises and vegetation.

Mr. Kennedy leaned on his contacts in the Obama administration to secure a $1.6 billion loan guarantee for the project in 2011. “I essentially saved the company,” Mr. Kennedy said in the 2012 deposition.

BrightSource also wanted to locate a massive solar power farm in a region of the Mojave Desert, on land previously earmarked for conservation. David Myers, president of the Wildlands Conservancy, was among its most vocal opponents, along with Senator Dianne Feinstein, the California Democrat who died this fall, and officials from the Sierra Club and the Center for Biological Diversity.

Mr. Myers said he had long admired Mr. Kennedy’s work in New York and was devastated by his involvement in pushing the California project. “He was like a hero, in his own mind,” Mr. Myers said. After a protracted fight, BrightSource walked away from the venture.

In the interview with The Times, Mr. Kennedy said he had sympathy for the point of view of the project’s opponents, but he believed it was vital to promote solar energy.

Ultimately, Mr. Kennedy worked for or served on the boards of at least 16 companies, all while juggling his speaking commitments, his duties at the nonprofits that were paying him and his obligations to his law firm. He joined the board of a holding company that owned a troubled for-profit college in New York, was a paid adviser to an Arizona environmental company known for hiring boldface names and was on the board of a Florida company that made red-light cameras.

Mr. Kennedy ended up on the board of that company, Smart Citation Management, because a friend knew he was hard up for cash and recommended him for the position, he said in the 2012 deposition. George K. Stephenson, the president of Smart Citation, described Mr. Kennedy as a “very engaged” board member.

At least one company with ties to the Kennedy family still has Mr. Kennedy on its payroll. Marwood Group, a political research firm, has paid him $10,000 a month for years, records show.

Its president and founder is Ted Kennedy Jr., Mr. Kennedy’s cousin. The company did not respond to requests for comment. Mr. Kennedy said he served as an adviser and consultant.

Around the time Mr. Kennedy spoke at Mr. Salzman’s house, he became interested in another topic: mercury in vaccines.

For years, Mr. Kennedy had been warning about mercury contamination from coal-fired power plants, and he has said that concern grew to include vaccines when the mother of a “vaccine-injured child” came to him for help. In 2005 he wrote an article, published in Rolling Stone and Salon, that blamed thimerosal, a mercury-containing preservative used in some vaccines, for a rise in autism in children.

Although both news outlets later withdrew the article after finding that some of its claims were wrong or dubious, and Mr. Kennedy was widely criticized by the scientific community, he dove headlong into his effort. He began giving speeches on the topic, and wrote a book about it in 2015. He did not give up his environmental work: That same year, he began taking about $200,000 in annual salary from Waterkeeper Alliance, a national organization with a mission to clean up waterways.

But he also joined the board of a nonprofit organization called the World Mercury Project, which aimed to eliminate mercury exposure in many arenas. In 2018, with Mr. Kennedy’s help, it was rebranded as Children’s Health Defense.

Mr. Kennedy proved to be an effective fund-raiser for the fledgling group, just as he had for his environmental allies, even selling $10 raffle tickets to win a tour of the Cape Cod compound. In 2021, the last year for which data is available, the group’s annual revenue was almost $16 million. With an impressive war chest, Children’s Health Defense has become one of the country’s leading spreaders of vaccine misinformation.

As Mr. Kennedy’s focus shifted more and more to vaccine skepticism, he parted ways with the environmental groups that had defined so much of his public life. In 2017 he told Tucker Carlson, then a Fox News host, that his vaccine work had made him a pariah in some circles and cost him work.

“It’s been probably the worst career move that I’ve ever made,” he said. When Mr. Carlson asked him if he was “getting paid for this,” Mr. Kennedy replied: “No, I’m not. In fact, I’m getting unpaid for this.”

Except for the Marwood Group, Mr. Kennedy no longer holds paid board positions, according to his F.E.C. filing, and he reported taking in a much-diminished $24,000 in speaking fees.

But his effort on vaccines has also been a source of income that would be impressive by many measures.

By 2021, the last full year for which data is available, he was making slightly more than $500,000 a year at Children’s Health Defense, up from $255,000 in 2019.

After writing his book about thimerosal, he returned to his publisher, Skyhorse Publishing, to write a scathing book in 2021 about Dr. Anthony S. Fauci, the federal government’s long-serving top infectious disease specialist who became a focus of rage for people skeptical of the coronavirus vaccine.

The book sold well, more than 500,000 copies in hardcover, according to Circana BookScan. Mr. Kennedy said he donated the proceeds to Children’s Health Defense, but he received a $125,000 consulting fee from the publisher over this year and last for referring other authors.

Similar to his playbook as an environmentalist, Mr. Kennedy has established profitable relationships with law firms, including one that handles legal work for Children’s Health Defense. Mr. Kennedy told The Times that because he believed his stance on vaccines had cost him income, he had an agreement with Children’s Health Defense to supplement his salary with outside legal work.

“I had these big bills that I just couldn’t pay on a badly diminished salary,” he told The Times.

“I said, ‘I need an opportunity to make more because that is not going to do it,’” Mr. Kennedy said. Under the deal, he would share the proceeds from any legal wins or settlements with the organization.

One firm, the California-based Wisner Baum, paid him $1.6 million over the 18 months ending in June, according to his F.E.C. filing. Over the years, he has worked on environmental cases for Wisner Baum, including as a lawyer on the team that won a $290 million judgment against the chemical giant Monsanto, the maker of Roundup weed killer.

More recently, however, Mr. Kennedy has been listed as co-counsel on dozens of lawsuits that Wisner Baum has brought against the pharmaceutical company Merck for injuries it says were caused by a vaccine formulated to prevent the transmission of human papillomavirus.

The Children’s Health Defense website also scouts clients for Wisner Baum, encouraging parents to call the firm if they believe their child might have been harmed by the HPV vaccine.

Another law firm, JW Howard Attorneys, paid Mr. Kennedy about $315,000 over the same 18-month period. JW Howard was one of the firms that handled a case brought by the Orange County Board of Education and Children’s Health Defense seeking to end the Covid-19 state of emergency that California declared in the spring of 2020.

And this past January, JW Howard was counsel on a lawsuit filed by Children’s Health Defense and Mr. Kennedy against The Washington Post, Reuters and other news organizations, accusing them of colluding to stop the publication of certain Covid stories, among other allegations.

Mr. Kennedy is also still a partner at Kennedy & Madonna. Between January 2022 and June 2023, he made $5 million for his work there, records show. The law firm, its website has emphasized, does not take vaccine cases.

Kitty Bennett contributed research.