FARGO, N.D. — The furious pace of energy exploration in North Dakota is creating a crisis for farmers whose grain shipments have been held up by a vast new movement of oil by rail, leading to millions of dollars in agricultural losses and slower production for breakfast cereal giants like General Mills.

The backlog is only going to get worse, farmers said, as they prepared this week for what is expected to be a record crop of wheat and soybeans.

“If we can’t get this stuff out soon, a lot of it is simply going to go on the ground and rot,” said Bill Hejl, who grows soybeans, wheat and sugar beets in the town of Casselton, about 20 miles west of here.

Although the energy boom in North Dakota has led to a 2.8 percent unemployment rate, the lowest in the nation, the downside has been harder times for farmers who have long been mainstays of the state’s economy. Agriculture was North Dakota’s No. 1 industry for decades, representing a quarter of its economic base, but recent statistics show that oil and gas have become the biggest contributors to the state’s gross domestic product.