The banners, T-shirts and handwritten posters said it all. "China! Hands off Vietnam!" read one. "Shame on you, bastard neighbour," said another. "Stop escalating, invading the East Sea of Vietnam," a third declared.

As the protesters weaved their way through the crowded streets of Hanoi, past the peeling colonial villas and upmarket shops selling stereos and Versace, they charged towards the Chinese embassy, where they hoped to make a stand against what they call "China's constant aggression".

"I hate China!" said one fortysomething protester, his voice hoarse from shouting slogans. "Germany invaded Poland during the second world war, now China wants to do the same to Vietnam. History may repeat itself if the international community is not made aware of China's bullying."

From government offices to the streets of Vietnam, tensions between Beijing and Hanoi have mounted in recent weeks over what China calls the South China Sea and Vietnam the East Sea, an area where vast deposits of oil and gas, important international shipping routes and fishing rights are of interest not just to Beijing and Hanoi, but also to the Philippines, Malaysia, Taiwan and Brunei.

But last month's protesters had only China on their mind. After detaining a group of Vietnamese fishermen near disputed islands this year, Beijing announced that the state-backed China National Offshore Oil Corporation was seeking bids for oil exploration in what Vietnam deems its own sovereign waters.

It also declared Sansha City – on tiny Yongxing in the Paracel islands, which Vietnam lays claim to – China's newest municipality. The anti-China protest was the third of its kind in Hanoi in one month. "The territorial ambition of China is a common threat – not only for the Philippines or Vietnam but for countries all over the world," said leading economist Le Dang Doanh, a former government adviser who recently signed an open letter calling for China to abandon its "absurd maritime claims" in the region. "China's territorial claims are now bigger than China itself."

Hanoi, 125 miles from the Chinese border, knows it must play a delicate game. Trade between the two countries reached an estimated $40bn last year, and analysts say that ties between the authoritarian, one-party states are considerably closer than either government would like to admit.

The seeming standoff has pushed the US into the game, with recent visits by the secretary of state, Hillary Clinton, and the defence secretary, Leon Panetta, highlighting America's interest in its former foe. Panetta's visit to Cam Ranh bay, a US naval base during the Vietnam war, sparked particular curiosity over the US's intentions to "protect key maritime rights for all nations in the South China Sea" as it moves to deploy 60% of its naval ships to the Pacific by 2020.

Carlyle Thayer, a Vietnam expert at the Australian defence academy, said Vietnam was likely to maintain its sovereignty by co-operating – but not aligning itself – with the US, but warned the situation in the South China Sea could worsen before it improved. "Most likely an incident will occur from a misadventure of two opposite boats trying to be in the same place at the same time," he said. "At the moment there's enough control [on both sides] but the analysis is that a lot of China's agencies are acting independently, and the central government is having a hard time asserting authority … the problem is that [neither country's] crisis management techniques are very good."

The protests in Hanoi come at a time of uncertainty over Vietnam's political and social future. Its economy has followed a remarkable trajectory from colonialism and communism through to the doi-moi ("socialist-oriented market economy") capitalism of the 1990s and beyond. Art-deco villas have been razed for multi-storey office blocks, and gaudy mansions dwarf the shady avenues of Ho Chi Minh City and Hanoi, where men in slacks and women in short shorts and stilettos skittle past in glossy Mercedes and 4x4 BMWs.

Here, the rich have become so rich that a Vietnamese businessman recently purchased an entire American town for sale in Wyoming. But Vietnam is running a huge trade deficit with China ($1.85bn in the first two months of the year alone) and its three million-member Communist party is struggling to maintain control over its population of 90 million, 70% of whom were born after 1975, and one-third of whom have internet access.

Protesters are not just angry about China's territorial ambitions, but about the gaping rich-poor divide, increasing accounts of police brutality, widening crackdowns on dissent, and growing numbers of land evictions and human rights abuses. Reporters without Borders declared Vietnam an "enemy of the internet" as a decree aimed at making it illegal to post anonymously online means that bloggers particularly are under attack. Facebook is blocked, as are many blogs, and activists claim emails, phone calls and whereabouts are routinely monitored. The Committee to Protect Journalists cites Vietnam as the fourth-worst jailer of journalists in the world. "Vietnam really is the new Burma," said Phil Robertson of Human Rights Watch.

"We're seeing more of a crackdown on freedom of expression, a growing lawlessness in terms of the way police interact with people, a continued effort to go after prominent bloggers, to identify activists and jail dissidents. They're trying to prevent any Arab spring-type event where a mixture of information on the internet combined with people being angry and protesting ignites into something more. It's very embarrassing for Vietnam, because previously they were the influential ones giving advice to Burma, which was the basket-case."

Now that Burma is no longer a pariah — thanks to the election of Aung San Suu Kyi to parliament and a slew of reforms initiated by reformist President Thein Sein — the shining star that was once Vietnam has waned considerably, says one local analyst. "Foreign direct investment is flowing into Burma and declining in Vietnam. The government knows it is losing credibility. Vietnam allowed its private sector to develop, but it did not reform its political system. It was a fatal mistake."

Dissident lawyer Le Quoc Quan, one of Vietnam's most prominent human rights activists who has been repeatedly jailed and beaten for his democracy efforts, said Vietnam was fighting a losing battle. "More people know more about their rights, so the more they fight for their rights, [the] more repression, more arrests," he said. "But an optimistic sign is that people are not afraid."

While it is hoped a diplomatic resolution over the South China Sea will soon be reached – the Association of Southeast Nations agreed last week to a "code of conduct" that may see negotiations begin with China in September – it is just as likely that tension will continue. "The problem of China and Vietnam has been a problem for 2,000 years," says Le Dang Doanh. "If China keeps up the aggression, one million [Vietnamese] will take to the streets to protest. You'll see."

• This article was amended on 7 August 2012. The original said that the USA will be moving 60% of its naval ships to the Pacific by 2020 rather than 10% more, ie the deployment ratio will be 40% of the fleet in the Atlantic and 60% in the Pacific.