China on Thursday sold $3 billion in U.S. dollar bonds, raising money as cheaply as some of America’s strongest companies at a time of heightened tensions with its largest trading partner and in the midst of a global markets selloff.

The successful sale shows foreign investors remain confident in China’s ability to repay debt, even though economic growth is slowing and the country is trying to keep a lid on corporate-debt levels. But because China is an infrequent issuer of U.S. dollar bonds, the new securities have a scarcity...