Admitted sex offender Anthony Weiner and his estranged wife Huma Abedin arrived separately to appear before Judge Michael Katz at The Supreme Court of New York for a hearing over their divorce on Wednesday.

In the hearing, Weiner was visibly upset, huffing and puffing while Abedin remained mostly expressionless. The hearing was brief, a prelude to what could be a long and acrimonious proceeding, although the judge stated that both wanted to resolve the divorce amicably.

The hearing came just days before Weiner is scheduled to be sentenced for texting obscene material to a 15-year-old girl on September 25.

Abedin, 41, a close aide to Hillary Clinton, filed for divorce on May 19, the same day Weiner, 53, pleaded guilty to federal obscenity charges related to explicit messages he sent to the teenager.

The former political power couple's seven-year marriage was strained by Weiner's repeated 'sexting' relationships with numerous women, including a college student, a porn star and a Las Vegas blackjack dealer.

The divorce case is contested, as Abedin is seeking full custody of their 5-year-old son.

SCROLL DOWN FOR VIDEO

Admitted sex offender Anthony Weiner and his estranged wife Huma Abedin appeared before Judge Michael Katz at The Supreme Court of New York for a hearing over their divorce on Wednesday (pictured)

Abedin remained mostly expressionless in court. The divorce case is contested, as Abedin is seeking full custody of their 5-year-old son

Abedin seemed to dominate the conversation when she sat next to the former congressman while keeping a cool expression, but Weiner could not match her poker face

Although Abedin stood by Weiner through recurrent sex scandals that destroyed his career, the final straw for their marriage was Weiner's months-long sexting relationship with a high school sophomore

During the hearing, Judge Katz acknowledged the two wanted to resolve their divorce amicably and added that he hoped to help them work something out that would work for their family.

He said: 'I certainly would encourage you to try to work out a plan together with your attorneys’ assistance.

'It certainly would be better for your son if you could do that. It would save you a lot of stress. Hopefully the financials can be worked out amicably as well.'

When the lawyers for the two parties went into a back room with the judge, the once happy couple moved to sit next to each other and talked quietly.

Abedin seemed to dominate the conversation while keeping a cool expression, at one point smiling, while Weiner could not match her poker face.

Both of their lawyers asked for privacy in the matter, but the judge allowed for a photographer to enter the courtroom because their attempts to keep their separation under wraps has not been successful.

Although they arrived separately, the two walked into the Manhattan courtroom together and then hurriedly left the building after 30 minutes, having a black car whisk them away.

Abedin stood by Weiner through recurrent sex scandals that destroyed his career but the final straw for their marriage was Weiner's months-long sexting relationship with a high school sophomore.

Both of their lawyers asked for privacy in the matter, but the judge allowed for a photographer to enter the courtroom because their attempts to keep their separation under wraps has not been successful

The judge acknowledged they wanted to resolve their divorce amicably and added he hoped to help them work something out that would work for their family

Abedin seemed to be able to keep her emotions in check and was composed during the hearing while Weiner walked into the room visibly upset

Although they arrived separately, the two walked into the Manhattan courtroom together and then hurriedly left the building after 30 minutes, having a black car whisk them away.

DailyMail.com first reported last September on Weiner's online affair with the teenager, during which he allegedly asked her to dress up in school girl outfits and participate in 'rape fantasies.'

The story prompted an FBI investigation into Weiner, when investigators stumbled across previously undisclosed emails from Clinton's private email server on Weiner's laptop.

The discovery led FBI director James Comey to reopen his investigation into Clinton's emails just days before the presidential election – a move Clinton has blamed in part for her election loss.

Abedin, who worked with Clinton for two decades and was a senior campaign aide, was said to be devastated after hearing the news.

'When we heard this, Huma looked stricken,' wrote Clinton in her new book What Happened. 'Anthony had already caused so much heartache. And now this.'

Abedin told Clinton: 'This man is going to be the death of me,' before bursting into tears.

Abedin is fighting for full custody of her son. Pictured: The parents walked their son Jordan to school on the first day of the school season on Friday

The couple met in 2001 when Weiner was a first-term congressman and Abedin was an aide to then-Senator Hillary Clinton. They were married at the Oheka Castle in New York in 2010

At one point, Abedin cracked a smile along with Weiner while their attorneys were in another room talking with the judge

Clinton said her long-time aide's anguish 'broke my heart' and made her determined to stand by Abedin despite the damage to her campaign.

The devastating revelation was one of many Abedin endured during her seven-year marriage to Weiner.

The couple first met in 2001 when Weiner was a first-term congressman and Abedin was an aide to then-Senator Hillary Clinton. Abedin was 25 at the time and already a seasoned Clinton insider, having worked for the former First Lady from the time she was 19.

Weiner has admitted he was interested in Abedin immediately, but said didn't ask her out to drinks until they bumped into each other that summer in Martha's Vineyard. The date didn't go well; Abedin ordered a cup of tea and quickly 'ditched' Weiner, according to his account.

But they reconnected romantically in 2007, after Abedin sent Weiner a flirty text message during the State of the Union to thank him for sitting next to Clinton at the speech.

'I appreciate you looking out for my boss,' she wrote.

Although Abedin stood by Weiner through recurrent sex scandals that destroyed his career, the final straw for their marriage was Weiner's months-long sexting relationship with a high school sophomore. Pictured: Weiner's texts to the young girl

Another of the inappropriate images Weiner sent showed him curled up with his then four-year-old son

At the time, Weiner was a rising star among House Democrats due to his combative style and regular appearances on cable news shows.

Abedin, meanwhile, was one of the closest confidantes to the woman who was expected to win the Democratic presidential nomination the following year.

Weiner and Abedin quickly cemented themselves as a political power couple and were engaged by 2009.

They married in 2010 in a lavish celebration at Oheka Castle on Long Island – a venue that runs $100,000 for the average wedding – with Abedin wearing a custom Oscar de la Renta gown and Bill Clinton officiating the ceremony.

But just one year later the couple's idyllic image would be shattered, when Weiner accidentally posted a photo of his underwear-clad crotch on Twitter while attempting to send it privately to a female college student.

The congressman deleted the photo and initially claimed his account was hacked.

But he eventually admitted that he had been sexting with numerous women, after several came forward to say they had exchanged explicit messages and photos with him.

In the midst of the controversy, Weiner resigned from Congress and said he was going to therapy to deal with sexual addictions.

Two years later, Weiner launched a political comeback with his campaign for New York City mayor. New Yorkers seemed poised to forgive his past transgressions, and the former congressman led in Democratic polls.

The girl who exchanges sexts with Weiner revealed her face on Friday. She is not being named because she is still a minor but her father gave permission for her face to be shown

But shortly before the primary election, news emerged that he had continued to send explicit text messages and photos to 23-year-old Sydney Leathers – causing Weiner's poll numbers to plummet and costing him the nomination.

In the 2016 documentary Weiner, which followed the former congressman throughout the mayoral campaign, Abedin looks alternately disgusted and distraught as news of her husband's affair went public.

'It's like living a nightmare,' she told the camera at one point.

Abedin finally announced that she was separating from Weiner last summer, after it was revealed that the former congressman sent another woman a lewd photo of his crotch while he was in bed with his 5-year-old son.

A few weeks later, DailyMail.com reported on Weiner's sexting relationship with a 15-year-old girl. Although the girl told Weiner she was in high school, the former congressman told her in messages that she made him 'hard' and said he wanted to 'bust that tight p***y so hard and so often that you would leak and limp for a week.'

The teenager said in an interview that Weiner would also chat with her on a video messaging program, during which he asked her to dress up as a school girl and talked about his 'rape fantasies.'

During the relationship, which started in January 2016 and carried on for several months, Weiner also sent her photos of him shirtless and posing provocatively.

There were reports that Abedin and Weiner were working to repair their relationship as recently as last spring. But that possibility was dashed on May 19, when Weiner appeared in a New York court to face federal charges

Investigators looked at Huma's laptop as part of their probe into her husband's affair. It crossed over into a separate FBI investigation into Hillary Clinton's use of a private email server

The girl, who showed her face publicly for the first time last week, said she initially decided to come forward about Weiner because she was disturbed he had sent women photographs of him posing with his young son.

After the scandal broke, Weiner spent several weeks at a rehab center for sex addiction in Tennessee.

Although Abedin and Weiner were technically separated last summer, they continued to live together in their $3.3million Manhattan apartment.

There were reports that Abedin and Weiner were working to repair their relationship as recently as last spring. But that possibility was dashed on May 19, when Weiner appeared in a New York court to face federal charges.

Weiner pleaded guilty to sending obscene material to a minor, a charge that could land him in prison for up to 10 years when he is sentenced later this month.

He broke down in tears and apologized during the hearing, telling the judge that he has a sickness.

'I have a sickness but I do not have an excuse,' he told the court.

Although Weiner could face up to a decade in prison, his plea agreement makes it likely he will be sentenced to far less than that. Prosecutors have asked for him to be sentenced to 21 to 27 months, and Weiner's legal team agreed not to appeal any sentence below that range.

Abedin filed for divorce hours after the hearing.