Calista Flockhart has spent $200,000 on her troubled brother after he had two run-ins with drugs and the law — trying desperately to keep him from suffering the same fate as her beloved co-star Robert Downey Jr.

In the past few months, the “Ally McBeal” star has spent a fortune trying to help Gary Flockhart, 41, turn his life around, a close source told The ENQUIRER. She bought him a badly needed new house and a sports utility vehicle, as well as paying for the lawyer who defended him in his second bust for heroin possession.

“I don’t want you to end up like Robert,” 37-year-old Calista told Gary.

“What happened to him nearly killed me. I want you to get better. Whatever I can do to help, I will.”

Calista is very close to her older brother, a truck driver who once generously sent her a case of ravioli to live on when she was a struggling actress, even though he had very little money.

“She began helping him in 2000 when she leased a Ford Explorer for him,” said the source.

Then on July 12, 2001, Gary was arrested for criminal trespass and possession of heroin. Although he got off with a light sentence, his worried sister tried again to ease the pressures on him by buying a new home for him. Gary had been living in Plymouth, Conn., with his wife Lorraine and stepson Steve Krampitz in a run-down house with a leaky roof, dangerous asbestos in the walls and a yard strewn with garbage.

“Calista hoped that if Gary didn’t have to struggle so hard to maintain that shack, he’d have fewer worries and a better chance to succeed,” the source said.

Calista Flockhart was a cheerleader in high school. (Shawnee High School in Medford, N.J.)

Calista paid $145,000 to buy Gary and his wife a three-bedroom house in Terryville, Conn., and the family moved in on October 31. But in spite of Calista’s loving generosity, Gary was soon in trouble again — busted on November 30 for possession and sale of illegal drugs.

“Calista was just crushed,” said the close source. “The repeat pattern reminded her of her friend Robert Downey Jr., whom she’d also tried so hard to help.”

Calista immediately shelled out $2,500 for a lawyer to defend Gary in court. A month later, when the lease was up on Gary’s SUV, she spent another $15,000 to buy the vehicle for him.

On March 1, Gary pleaded guilty in court to possession of a controlled substance, and was given three years of probation. His loyal sister has stood by him through it all.

“Calista calls her brother constantly, offering encouragement,” said the close source.

“She’s not about to give up on her brother.”