President Biden is set to give final approval on Friday to the biggest reshaping in generations of the country’s Uniform Code of Military Justice, stripping commanders of their authority over cases of sexual assault, rape and murder to ensure prosecutions that are independent of the chain of command.

By placing his signature on a far-reaching executive order, Mr. Biden is set to usher in the most significant changes to the modern military legal system since it was created in 1950. The order follows two decades of pressure from lawmakers and advocates of sexual assault victims, who argued that victims in the military were too often denied justice, culminating in a bipartisan law mandating changes.

In a statement, the White House called the changes made by the executive order “a turning point for survivors of gender-based violence in the military” and said they kept promises Mr. Biden made as a candidate.

“He’s made clear that our one truly sacred obligation as a nation is to prepare and equip those we send into harm’s way, and to care for them and their families both while they are deployed and when they return home,” the statement said. “The reforms implemented through today’s executive order do just that.”

The changes had for years been opposed by military commanders. But they were finally embraced by the Pentagon in 2021 and mandated by a law spearheaded by Senator Kirsten Gillibrand, Democrat of New York. Mr. Biden signed the landmark legislation into law two days after Christmas that year.

The law set up a two-year process for the Defense Department to create a cadre of special prosecutors to handle sexual assault and a handful of other high-profile crimes. The Offices of Special Trial Counsel, as they will be called, will be staffed by experienced military prosecutors who will report to the civilian leaders of the military’s branches.

The final step needed to change the Uniform Code of Military Justice under the law was a presidential executive order. Lawmakers directed Mr. Biden to issue it by December 2023. White House officials said Mr. Biden would do so on Friday, more than five months ahead of the deadline.

Under the rules established by Mr. Biden’s order, commanders in the military will no longer have the authority to decide whether to pursue charges in cases of sexual abuse and a handful of other serious crimes. Instead, that decision will fall to the new, specialized lawyers, White House officials said.

The decisions by those special prosecutors will be final and binding, and cannot be overridden by military commanders.

For years, advocates of sexual assault victims in the military complained that their cases were not taken seriously and were in many cases blocked by the commanders of the service members making the accusations. Over time, complaints grew — especially among young people — about the Pentagon’s tepid response to sexual assault cases.

Members of the top military brass were for years among the chief opponents of changing the code of justice for the armed forces. But that gradually changed. Defense Secretary Lloyd J. Austin III, a retired Army general, endorsed the changes in 2021. Gen. Mark A. Milley, the chairman of the Joint Chiefs of Staff, had long opposed them, but acknowledged that same year that younger enlisted troops no longer had confidence that sexual assault cases were being taken seriously by the military’s command.

The fading of the military resistance provided the opportunity for bipartisan negotiations, eventually leading to the law in 2021 and, on Friday, Mr. Biden’s executive order.

The move to change the military justice system was also galvanized by the 2020 case of Specialist Vanessa Guillen, whose burned and mutilated body was discovered after she had tried to report instances of sexual harassment by another soldier, who the Army said killed her and later himself.

That case and others were frequently cited by Ms. Gillibrand and other female lawmakers, including former Representative Jackie Speier, Democrat of California, and Senator Joni Ernst, an Iowa Republican who is a retired National Guard lieutenant colonel. Ms. Ernst said her own experience as a victim of sexual assault informed her views on the issue.

White House officials said that the military branches had already begun hiring for the Offices of Special Trial Counsel, which they expected to be fully operational by the end of the year. But they conceded that it would take years to measure how the changes affected the culture surrounding the prosecution of sexual assault and other serious crimes in the military.

Under the executive order, the special trial counsel offices will have their authority expanded in 2025 to include cases of sexual harassment.