DETROIT—The global shortage of computer chips and other parts has forced General Motors to build some 95,000 vehicles without certain components during the second quarter.

The automaker said that most of the incomplete vehicles were built in June, and that it expects most of them to be finished and sold to dealers before the end of the year.

The unsold vehicles amounted to 16 percent of GM’s total sales from April through June. The company sold more than 582,000 vehicles during the quarter, down more than 15 percent from a year ago.

The shortage has limited the supply of new vehicles on dealer lots in the U.S. to around 1 million, when in normal years it’s about 4 million at any given time. That has pushed prices to record levels and limited vehicle selection, but it’s also led to strong profits for most automakers.

GM reaffirmed its full-year net income guidance of $9.6 billion to $11.2 billion with pretax earnings of $13 billion to $15 billion. For the first time the company predicted that it would make $2.3 billion to $2.6 billion before taxes in the second quarter.

In a prepared statement, GM said its North American production has been relatively stable since the third quarter of last year, but short-term parts disruptions are continuing. “We are actively working with our suppliers to resolve issues as they arise to meet pent-up customer demand for our vehicles,” the statement said.

Most automakers have predicted minor improvement in the chip shortage during the first half of the year, with far better supplies from July through December.