General Vo Nguyen Giap, who has died aged 102, was a self-taught soldier who became one of the foremost military commanders of the 20th century. He used his charisma and tactical skills to transform a tiny band of Vietnamese guerrillas into an army that defeated both France and the US.

In 1944 he founded the Armed Propaganda Brigade for the Liberation of Vietnam, gathering together 31 men and three women armed with flintlock rifles. By 1954, he had turned this ragtag group into the Vietnamese People's Army that defeated the French at the battle of Dien Bien Phu. The surrender of French forces after a 55‑day siege in this valley in north-western Vietnam was the coda for colonialism in Indochina.

The victory took Vietnam to the negotiating table but it did not bring peace. Instead the Geneva Accords divided the country into the communist north and US-backed south, setting the stage for another war that was to last until the defeat of the US and the Saigon government in 1975.

Giap, an elfin lawyer with an intellectual bent, was an unlikely warrior. He often claimed his only military lesson came from an encyclopedia entry describing the mechanism of a primitive hand grenade. The reality was a little different. As a child his sense of nationalism had been nourished with stories of heroic Vietnamese generals and their victories against the Chinese and Mongols. At the Lycée Nationale in Hue, the same school that produced the North Vietnamese president Ho Chi Minh and the South Vietnamese leader Ngo Dinh Diem, he became involved in the anti-colonial movement.

He earned a degree in law at the University of Hanoi and began teaching history. By the time he founded his army, posing at the first swearing-in wearing a white suit with a Mauser pistol in his belt, he was well versed in Marx and had read Mao Zedong's writings on guerrilla warfare. He would always deny the obvious influences of Mao and Napoleon, saying: "We fought our wars in a Vietnamese way. My only influences were the great strategists of Vietnamese history."

In 1940 Giap joined Ho Chi Minh in China. They returned to Vietnam a year later and founded the Viet Minh, which briefly took power in the August Revolution of 1945, when the Vietnamese communists filled the vacuum left by the defeated Japanese forces. Giap began talks with the French on independence, but they were determined to return to Vietnam and in December 1946 the Viet Minh began an eight-year war.

Poorly armed and trained, the Viet Minh made little headway until after 1949, when Mao had taken control in Beijing. China began sending advisers and supplies to help the Vietnamese. For the first time Giap had access to heavy weapons but his first direct confrontation with the French forces was a 1950 battle in the Red River Delta that proved disastrous for the Vietnamese, who lost some 20,000 men. His luck turned in 1954, when General Henri Navarre decided to set up camp in Dien Bien Phu to protect Laos from the guerrillas. The French settled into the broad valley, confident that the surrounding mountains would protect them from the Viet Minh.

They had not accounted for Giap's skill in mobilising forces and keeping them supplied. Tens of thousands of farmers were drafted to carry dismantled artillery and weapons into the hills around Dien Bien Phu. Reinforced bicycles were loaded with hundreds of pounds of supplies and pushed up muddy tracks. Giap would later recall that it would take 21kg of rice for the porters for each kilogram of the staple that arrived to feed soldiers laying siege to the French.

Viet Minh artillery rained hell down on the French troops from the surrounding hills. After the airfield was closed, provisions could only be dropped in by parachute. On 7 May the French surrendered. On the same day talks opened in Geneva to end colonialism in Indochina.

The cost of Giap's victory at Dien Bien Phu had been extremely high. His forces suffered massive casualties, many times the toll inflicted on the French. A horrendous loss of life marked all Giap's victories, but he was coldly unapologetic, saying the number of dead was small compared with the number who died each day of natural causes.

After 1954, Giap became defence minister in the Democratic Republic of Vietnam. Almost immediately the government ran into serious problems when the population turned against a brutal Maoist campaign of land reform in which thousands of people were killed after being condemned as landlords. With their political base shaken, the Communist party sent out Giap to restore order. His apologies for the party's excesses were grudging at best, but using his popular support as the hero of Dien Bien Phu he was able to calm the angry crowds, which included many of the soldiers who had fought under him.

In 1960 the politburo decided to launch the fight for reunification of North and South Vietnam. It was a time of increasing tensions and disagreements in Hanoi. After straddling the Sino-Soviet split that ripped apart the communist world in 1960, Hanoi turned towards Beijing and relations with the Soviet Union were strained. Giap had always harboured a streak of resentment against the Chinese, whose advice at Dien Bien Phu he claimed to have ignored. He became staunchly pro-Soviet at a time when his comrades were leaning towards Beijing. In the midst of the power struggles and purges that afflicted the elite of Vietnamese communism, Giap was even accused of trying to foment a coup d'etat with aid from Moscow.

General Vo Nguyen Giap (top left, smiling) with Ho Chi Minh (second right) during a military campaign in Vietnam in 1950. Photograph: AFP/Getty Images

Giap was an unusual figure in the anonymous hierarchy in Hanoi. He had not forged links with the others in French jails where revolutionaries earned their political stripes. He had escaped to China ahead of the French in 1939, his tracks covered by his wife Quang Thai, with whom he had a daughter, and who later died in prison. He could be imperious and frosty, which, combined with his aggressive temper, earned him the nickname "the snow-covered volcano". He was often querulous and rudely didactic, traits that come across in his many books on warfare. With his well-cut uniforms, curtained Russian limousine and grand French villa in the centre of Hanoi, Giap did not even pretend to follow the puritanism that the leadership affected.

Tensions were exacerbated when Giap's tactics against the US forces after 1965 achieved only mixed results. He was kept off guard by the mobility of American helicopter cavalry and his forces suffered an enormous number of casualties in battles they might have avoided. General William Westmoreland, commander of the American forces, once remarked that any US general that suffered Giap's losses would have been sacked instantly.

His skills lay less in military tactics and more in managing the logistics and politics that were so vital to sustain the war in the south. His diplomatic skills kept open supply lines from China and the Soviet Union, while at home he organised the movement of troops and material down the Ho Chi Minh Trail, a vast web of tracks stretching into Laos and Cambodia. "People should not be overawed by the power of modern weapons," Giap wrote. "It is the value of human beings that in the end will decide victory."

On 30 January 1968, tens of thousands of communist troops launched the Tet offensive, striking across South Vietnam during what was supposed to have been a truce to mark the lunar new year holiday. A suicide squad stormed into the US embassy compound in Saigon. The Viet Cong took over the former imperial capital of Hue. In Hanoi, the leadership had expected the South Vietnamese to rise up and overthrow the government but instead the VC suffered a huge military defeat. Their troops and command structures were nearly wiped out when the US forces regained control.

The offensive was a severe military setback for the North, but they did win a psychological victory. Dramatic news coverage of the offensive in the US damaged claims in Washington that an end to the war was in sight. Support for the conflict and for President Lyndon B Johnson slumped. Once again, Giap had suffered enormous losses but had still managed to declare victory. "After the Tet offensive, the Americans moved from the attack to the defence," he said. "And defence is always the beginning of defeat."

That defeat would take another seven years of fighting, less time than Giap had expected. The South Vietnamese army collapsed precipitously as the North Vietnamese pushed down the coast. Saigon fell on 30 April 1975.

Giap was the first general to defeat the forces of the US in a war. Flushed with the arrogance of their massive victory, the leadership in Hanoi pushed for an immediate reunification of North and South, and expanded its experiment in Soviet-style economics across the country. But although well-suited to winning a war, the government was inept at running a peace. Giap was said to have opposed the extreme economic measures, but his power was at a low. In December 1978, against Giap's advice, Vietnam invaded Cambodia to oust the Khmer Rouge. Although the initial victory was rapid, Vietnamese forces were to get bogged down fighting a guerrilla war against the Khmer Rouge that would last more than 10 years.

Giap's opposition to that war earned him a period in the wilderness. He was replaced as defence minister in 1980 and two years later lost his seat in the politburo. He remained a deputy prime minister in charge of science and technology, and was given the job of heading a national birth control campaign.

For most of the 1980s, Giap was a political outcast, occasionally wheeled out on ceremonial occasions but stripped of all real power. He did, however, command loyalty in the military, particularly among those officers disaffected by the war in Cambodia and angered by the economic collapse in the 1980s.

In 1986, in the runup to a Communist party congress, a group of officers urged Giap to take control and launch sweeping changes to the economy and political system. Giap refused, terrified of what might happen if he failed. Bui Tin, an army colonel who had been a protege, urged him again in 1990 to take over and provide a new direction for Vietnam. Giap demurred, preferring a comfortable retirement. Tin later condemned him bitterly, quoting an old Chinese saying that "the reputations of generals are built on the bodies of 10,000 men".

General Vo Nguyen Giap in 1994, the 40th anniversary of the defeat of the French at Dien Bien Phu. Photograph: Catherine Karnow/Corbis

Giap's political timidity came as a crushing disappointment to many. His last years were spent polishing his image as the "red Napoleon". He adored giving interviews, charming his hagiographers and fawning journalists with the same gestures and stories told in a fluent but outdated French of which he was immensely proud. He was always careful to avoid the real questions that hung over his increasingly contested career. He could not, however, stop many people from reconsidering his versions of history and heroism. Many Vietnamese also began to question whether the sacrifices of war had been worth it. Others saw too many moments in Giap's career where he had refused to stand up to hardliners or had failed to capitalise on his popular support to force through political and economic changes.

In 1991 Giap stepped down as vice premier. In a sign of his political disfavour, his 80th birthday passed without celebration and it was not until the 40th anniversary of Dien Bien Phu that he was given a measure of rehabilitation. He spent his retirement travelling and meeting foreign dignitaries, including, in 1995, his opposite number during the war, the former US defence secretary Robert McNamara.

In 1946, Giap married secondly Dang Bich Ha. They had two sons and two daughters.

• Vo Nguyen Giap, soldier, born 25 August 1911; died 4 October 2013