How Jennifer Garner helped Ben Affleck turn his life around

While they separated nearly two years ago, Ben Affleck's estranged wife, Jennifer Garner, has been instrumental in helping the Oscar-winning star get his life back on track after years of struggling with alcoholism.

Affleck took to Facebook on Tuesday to reveal that he'd completed treatment for alcohol addiction, and thanked his wife for her support, writing, "I'm lucky to have the love of my family and friends, including my co-parent, Jen, who has supported me and cared for our kids as I've done the work I set out to do."

ET is taking a look back at the couple's long relationship to see how Garner helped Affleck turn his life around.

WATCH: Ben Affleck Completes Rehab for Alcohol Addiction: I Want to 'Be the Best Father I Can Be'

A Change From the Start

A source close to Ben tells ET that the "Live by Night" star has been dealing with his addiction and dependency issues on and off for years. However, when Affleck and Garner began dating in 2004, the actor's close friends began to notice a change.

The source says that Affleck began to settle down and quit partying when the pair got together -- long before they welcomed their first child, daughter Violet, in 2005 -- and that the change lasted for a long time.

Raising a Family

Affleck and Garner tied the knot in June 2005, and by December the couple welcomed their first daughter. Their second daughter, Seraphina, was born in January 2009, and their son, Samuel, arrived in February 2012.

Through sharing a family with Garner, and having the added responsibility of fatherhood commanding his attention, Affleck said that being a parent helped his change his perspective for the better.

WATCH: Jennifer Garner Steps Out For Coffee as Ben Affleck Reveals Alcohol Addiction Treatment

"I think becoming a father makes you see the world differently and it's good," Affleck told The Guardian earlier this year. "I'd always had a strong idea about my values and the direction I wanted to be headed in, then I ran into getting famous and it totally spun me around and I flailed around for a few years."

In the statement he released on Tuesday after completing treatment, Affleck said his decision to seek help was motivated by his desire to set a good example for his kids.

"I want to live life to the fullest and be the best father I can be," he wrote. "I want my kids to know there is no shame in getting help when you need it, and to be a source of strength for anyone out there who needs help but is afraid to take the first step."

MORE: Happier Times: 7 Moments Ben Affleck & Jennifer Garner Were Absolutely Adorable

A source told ET that, for Affleck, "Family always comes first."

"Ben has struggled with alcohol for years and it's a struggle that millions of people have to battle every day. He has nothing to hide and wants his kids to know that he did everything he could to be a better father," the source said. "That's why he announced it himself."

Coming Back From Rock Bottom

In the early 2000s, around the time of Affleck's relationship with Jennifer Lopez, the actor appeared in a string of critically panned and commercially unsuccessful films, including "Daredevil," "Gigli," "Paycheck," "Jersey Girl," and "Surviving Christmas." It was a period of time in which Affleck felt like he was "the lowest rung of cool and talented that you could possibly be in the public consciousness."

Affleck got candid about his career doldrums in June 2016, while sitting down with Bill Simmons on his now-canceled HBO talk show, "Any Given Wednesday," adding that it was around then that he realized he wanted to take his career in a different direction

"That was kind of where I found myself when I thought, 'Hey, I want to take up directing,'" Affleck recounted. "So I was gonna work as hard as I could. I thought, 'If I'm gonna fail, I'm not gonna fail for lack of hard work,' and that became my mantra. I [was] just gonna work harder than everybody else."

WATCH: Ben Affleck Credits Jennifer Garner With Career Revival, Won't Co-Star With Her Again

But he didn't manage to pull off his popular resurgence alone. "I got sort of obsessed with [working hard], and my wife was really, really instrumental in me doing a lot of that work," the filmmaker shared.

Affleck went on to direct the acclaimed dramas like "Gone Baby Gone," "The Town" and "Argo" during his marriage to Garner. As an actor, his return to grace kicked off when he played George Reeves in the 2006 biopic "Hollywoodland," followed by a celebrated cameo in "Smokin' Aces," which both came out in 2006, two years after the pair tied the knot.

In December 2015, Affleck elaborated on his wife's impact on his career in an interview with Loaded magazine, sharing, "Getting to know Jennifer, falling in love with her and being connected with her gave me a foundation to reach out and say, 'Okay, I'm going to do 'Hollywoodland.' I'm going to direct 'Gone Baby Gone.' Those were the steps forward I needed to put positive stuff on the board."

WATCH: Ben Affleck Continues to Praise Jennifer Garner as 'Greatest' Mom, Calls Taylor Swift a 'Role Model'

Staying Strong Through Common Interests

While the couple were married for 10 years, they both dedicated themselves to different charities and philanthropic endeavors and came out to support each other as often as they possibly could.

In November 2014, Affleck lent his star status to the Save the Children Illumination Gala -- where Garner serves as a board member -- and delivered a rousing speech at the black tie event, praising his wife's dedication to the cause.

WATCH: Jennifer Garner on Teaching Her Kids to Be 'Citizens of the World': It's the 'Best Thing You Can Do'

"My wife is no f**king joke," he said in his oration. "There are a lot of celebrities, forgive me for saying, who are dilettantes and go and take a picture holding a kid's hand in a hospital, and you never hear from them again. My wife is the opposite of that."

With that kind of intense dedication to each other's goals, the couple showed a level of emotional support that formed the close friendship that was the basis for their relationship.

In 2014, Garner spoke with The Globe and Mail where she dished on the importance of maintaining their closeness.

WATCH: Jennifer Garner and Ben Affleck Vote Together on Election Day -- See the Pic!

"We're in the thick of it. Our kids are little, our careers are big, our lives are huge. We just focus on what's important, and staying friends," Garner said. "We have all the other stuff, too, but if you're going long, friendship has to be at the base of it."

The pair even made their charitable work a family affair in March 2015, when Garner brought Violet to Washington, D.C., to sit in the gallery while Affleck testified before the Senate Appropriations Committee about the importance of aid to Africa.

PHOTOS: Ben Affleck and Jennifer Garner: A Look Back at Their Romance

The Power of Kindness

Affleck has never had a negative thing to say about his estranged wife -- before or after they split up -- and it's clear from every interview he's ever given that he thinks of her as a gleaming beacon of kindness and generosity.

In fact, the actor said in an interview with the Toronto Sun in 2012 that he's "daunted" by Garner's sweetness on a daily basis.

"She does have a fundamental kindness and empathy in her that I think is rare, and incredibly appealing and wonderful," Affleck shared. "She's definitely atypical of someone in this business because this business tends to cultivate a kind of solipsism, narcissism -- almost demands it -- so resisting it and being someone who's the antithesis of that is really unusual. It's one of the things I really love about her."

While his wife resisted the common tendency among stars to slip into a realm of rampant egomania, it seems that she also helped Affleck resist the urge to succumb to his vices -- another common tendency in Hollywood.

MORE: 17 Times Jennifer Garner and Ben Affleck Were Our Relationship Goals

Garner often spoke of spending as much time as she could with Affleck, and how they connected on a lot of different levels.

"Ben is sexy and kind, but he's also a riot," she told Parade magazine in 2010. "We can be very goofy together. You steal the time. You steal a date, you steal a kiss, you steal a whisper. You sit next to each other on the couch with computers on your laps. After the kids are asleep you...well, you know. Whatever it is. You slip away for a night."

Strong Bonds Even After Their Split

Even after their split, Affleck and Garner remain close, frequently traveling together, going to church together, living together, and doing their best when it comes to co-parenting. Sitting down with Ellen DeGeneres in January 2017, Affleck called Garner "the world's greatest mom," and he's never seemed to waiver with his praise.

Garner, who has called their living situation the perfect example of a "modern family," said the friendship they forged as a couple has carried them through while raising their children together as a unit, even after their relationship came to an end.

WATCH: Jennifer Garner Talks Her 'Modern Family' With Ben Affleck, Says 'It Has to Be' About Their Kids

"He and I are great friends," Garner said in an interview with the Today show in August 2016, while explaining why she took the kids to visit their dad while he was filming in England.

"Ben was working in London on Justice League, and I thought, 'Well, the kids should have that experience,'" she shared. "[So] we just all went en masse."

WATCH: Ben Affleck Opens Up About Co-Parenting with Estranged Wife Jennifer Garner: 'We Try Our Best'

In February 2016, Garner opened up about her failed marriage to Vanity Fair in a tell-all interview, where she admitted, "I didn't marry the big fat movie star; I married him��� And I would go back and remake that decision. He's the love of my life. What am I going to do about that?"

While Affleck may be the love of her life, it doesn't seem that the estranged couple are any closer to reconciling now that he's undergone treatment for his addiction.

WATCH: Ben Affleck and Jennifer Garner Split: 'Not One Thing Has Changed,' Source Says

A source told ET earlier this month, "Nothing has changed on the Jen front. Their relationship is still the same as it has been since announcing their separation."

Additional reporting by Jennifer Peros and Lauren Zima.