BAGHDAD, Iraq (CNN) -- When British forces fully withdraw from Iraq on Friday, it will be the second time in a century that Britain will leave this nation with a legacy of war dead.

Mechanics prepare a tank ready to shipped back to the UK from Basra.

In the Baghdad North Gate War Cemetery rest thousands of British soldiers killed in a protracted military campaign during World War I, after which Britain established an occupying regime in Iraq.

In the peak of the latest war that began in 2003, about 46,000 British troops were stationed in and around Iraq. Now, almost all British troops are being pulled out because an agreement that allows them to remain in Iraq expires Friday, according to the British Ministry of Defence.

Britain leaves Iraq this time with 179 of its own dead.

"It's been a tough six years, no doubt about that," said Jon Wilks, the deputy head of the British mission. "But I think what we left behind is a solid base on which to build."

The British were based in southern Iraq, primarily in Basra, Iraq's second largest city that sits close to the Persian Gulf.

"We have in many sectors left Basra in a better state than when we arrived in 2003."

Then, after the U.S.-led invasion, Iraqis welcomed British troops. They were hailed as the force that would save the area's predominantly Shiite population from Saddam Hussein's persecution.

But the mood turned when liberation was not followed by a quick withdrawal.

Don't Miss

"It became the opposite of what we were wishing for," said Mustafa Atia, a member of the Basra provincial council."

Hope started to turn to fear.

By the end of 2004, extreme Shiite militias were gaining control of Basra. It seemed British forces had been sidelined as the militias enforced their own brand of laws.

In September 2007, British troops withdrew completely from Basra and southern Iraq was touted as the coalition forces' success story.

But Basra was left reeling.

The British-trained Iraqi police had been infiltrated by militiamen; the Iraqi Army struggled to keep them in check.

Women bore the brunt of the militia's brutal rule -- executed for "un-Islamic" acts like wearing tight jeans and lipstick. Or in the case of one woman, living alone.

Sabriya, identified only by her first name for security reasons, recalled her sister's plight.

"They said, 'Why don't you have a husband?'" Sabriya said. "They came in at night and put a pillow on her face and shot her in the head."

In March 2008, the Iraqi government launched Operation "Charge of the Knights" to battle Basra's lawlessness. The city was flooded with Iraqi soldiers and their U.S. advisers. The British were drawn back into the thick of the fight, their Mastiff and Warrior armored vehicles once again on the streets of the southern port city.

"The situation was awful, mainly because militias controlled the security forces," said Iraqi Gen. Aziz Swady, who was dispatched to Basra as part of the operation. "But after this operation, the citizens started to trust the Iraqi security forces."

Basra began piecing itself back together.

On Friday, as the British leave Iraq behind for a second time, they are left to ponder the fragility of Basra's situation -- and their own sacrifices. The question that could linger is: Was it worth it?