A man and a 5-year-old boy were killed and a third person was critically injured in two separate crashes on the Maine Turnpike in the Wells-Kennebunk area Friday afternoon, leading to an 8-mile backup that stretched into the night.

The crashes happened at mile 22 and mile 24, between the Wells and Kennebunk exits, said Maine State Police. The two fatalities came from a crash between a car and a tractor-trailer on the northbound side of the turnpike near mile 22 in Wells about 2 p.m.

That collision occurred as traffic was slowing because of another crash on the southbound side of the highway. Police said a vehicle traveling erratically at mile 24 in Kennebunk hit the median guardrail. The driver was thrown from the vehicle and taken to a hospital with critical injuries, said state police spokesman Stephen McCausland.

McCausland said the northbound crash happened when a box truck hit the rear of a car driven by Earl Gray, 57, of Waterboro. The truck landed on top of Gray’s car after hitting it, McCausland said, and the impact of that collision pushed Gray’s car into a tractor-trailer in front of the car.

Gray was killed along with Wyatt Frost, 5, of Lyman. McCausland said Gray was a volunteer driver with York County Community Action and had been providing transportation to the boy for a couple of years.

The driver of the box truck, John Kamau, 56, of Lowell, Massachusetts, was delivering mail from New Hampshire to Portland.

Kamau and the driver of the tractor-trailer had slight injuries, but did not need to be taken to a hospital, said McCausland, who also said the trooper’s crash report will be sent to the York County District Attorney’s Office for review.

McCausland did not identify the driver of the tractor-trailer or provide any more information on the driver who was ejected from the car on the southbound side of the turnpike.

Northbound travel lanes were closed until after 7 p.m., nearly five hours after the crash. At 8:30 p.m., the Maine Turnpike Authority sent out a tweet saying that delays along the stretch of turnpike where the crashes occurred had cleared.

Earlier, McCausland said state police would try to check on people in the hundreds of cars that got caught in the backup.

Troopers would “assist with vehicles that may have run out of gas and are now disabled,” McCausland said.

One of those caught in the traffic was Doug Most, an executive with The Boston Globe, who said he and his wife were on their way to Portland for the weekend.

They spent the afternoon and early evening stuck in traffic about a mile south of where the northbound crash occurred.

Most, who spoke to other drivers, said they were mindful of the fatalities just north of them and he didn’t want to appear insensitive to that. But he said drivers were frustrated by the lack of information hours after the crash closed the turnpike. Troopers routed traffic off the turnpike at the Wells exit, then up Route 1 to Kennebunk and back on the turnpike.

But many divers, like Most, were north of the Wells exit and had to wait while ambulances and firetrucks arrived and troopers began investigating the crash, taking measurements and cleaning up debris.

Most said he checked Facebook and Twitter often and found only “vague and not specific and not very frequent” posts from officials about what was happening.

He said people were upset with state police and turnpike officials for not keeping them informed. He said they could have easily provided more information on social media and might have even sent a cruiser through the clogged traffic using a public address system to provide updated information.

At 6:58 p.m., the turnpike authority sent out a tweet that read: “To those stuck in traffic we are so sorry. We continue to ask State Police when traffic will be allowed to move. We are thinking of you.”

The first word that the turnpike was open came in a tweet at 7:11 p.m. from the turnpike authority.

Erin Courtney, spokeswoman for the turnpike authority, said police told turnpike officials that the northbound lanes had to remain closed until the crash area was cleared.