They received some Soviet assistance in the early days which helped get them on the right track (e.g. gaseous diffusion, implosion). During the Sino-Soviet split, the Soviet advisors all withdrew and the Chinese had to re-develop the technology natively, albeit with some existing infrastructure (at first they tried to just run the plants in an ad hoc way, and this produced several accidents and required them to re-learn it all from not-quite-scratch).
As for how it did it — they made it a top priority, which meant funneling the best people they had to it, and sparing no expense (expenses got spared elsewhere in their society, to put it another way). They did run into problems because of intellectual diaspora and the Cultural Revolution (though it should be said that weapons programs in many countries with issues of this sort can serve as "shelters" for scientists and intellectuals, because their military requirements can trump their counter-productive ideological impulses). It was difficult.
It took them around decade to develop the technology for a bomb (they started in 1955, they detonated their first bomb in 1964). It was not an overnight affair. By contrast, the US took about 2.5 years to make a bomb after they committed to doing it, the Soviets took about 4 years, the British took around 5. So the Chinese program was on the longer side (which is no criticism — it is just a reflection of the difficulties they faced).
By the late 1950s and early 1960s, pretty much any nation that had a lot of resources to commit could develop nuclear weapons. They were expensive, but no longer mystical. Much of the science and technology had been declassified in the USA and USSR. The fact that it could be done, and the basic ways that it was done, were no longer secrets. China's detonation of their bomb was a major spur for the other powers of the world to pursue a Nuclear Non-Proliferation Treaty, because they realized that if a relatively poor, not-always-well-managed (e.g. Cultural Revolution) nation could pull it off with enough time and will, then anybody could.
But once they got it really rolling, they showed themselves to be extremely competent at weaponization of the concepts, and moving from fission to thermonuclear technology. They caught the United States considerably off-guard with some of their technical accomplishments (e.g. starting with an HEU implosion bomb, rather than a plutonium bomb).
The best account of the early Chinese bomb program is still John Wilson Lewis and Xue Litai, China Builds the Bomb (Stanford, California: Stanford University Press, 1988). Because our knowledge of their program is almost entirely dependent on what the Chinese government has released on it (and they have not released a whole lot), there are still many blanks in our understanding of their program. For a view of the Chinese program from above (satellites), see Jeffery Richelson, Spying on the bomb: American nuclear intelligence from Nazi Germany to Iran and North Korea (New York: W.W. Norton and Co., 2006), chapter 4.