A passenger train carrying people home after the holidays has slammed into a truck in rural South Africa, killing at least 18 people and injuring about 260 others, authorities said.

Officials said the truck driver allegedly tried to cross the tracks just ahead of the oncoming train, part of which burst into flames after the collision, trapping some passengers in carriages.

Those who were able to escape with their luggage hurriedly dragged bags from the smoking wreck to a nearby road.

"The truck driver was taking chances. He thought that he was going to pass through," Transport Minister Joe Maswanganyi said.

"Little did he know that the train was going to hit him. That has cost a lot of lives."

Some of the dead were badly burned, said Mthuthuzeli Swartz, acting CEO of the state-owned passenger rail agency.

The train, carrying 429 passengers, had been traveling from Port Elizabeth to the country's commercial hub of Johannesburg.

The collision occurred between the communities of Hennenman and Kroonstad in Free State province. It derailed half a dozen carriages, and power lines were damaged.

The truck driver emerged unscathed and the train driver and his assistant suffered minor injuries, Mr Swartz said.

He told local media outlet eNCA that the truck, towing two trailers, was halfway across the track when it was hit by the train and dragged for 400 metres.

"Human error" caused the accident, he said. Investigations are continuing.

South Africa has the continent's largest railway network, but it has been plagued by mismanagement and under-investment that has seen train use dwindle despite it being the cheapest form of public transportation.

In a recent report, the Government's Rail Safety Regulator (RSR) said that, in the 2016/17 financial year, 495 people lost their lives in the country's railway environment and 2,079 were injured.

The death toll was up 5 per cent from the previous year.