The Amtrak train sat stranded Sunday evening on a track in the Wilmington, Del., area with hungry passengers aboard.

So someone on the train dialed up a nearby pizza joint, Dom’s NY Style Pizzeria, and asked whether they would deliver some pies to the train.

At first, the clerk at Dom’s wasn’t sure. So he turned to longtime pizza delivery man Jim Leary and asked, “Can we deliver to a stuck train?”

Leary replied: “Oh yeah. We can do it.” Leary, who has been delivering pizzas for 18 years, recalled the story Monday as he prepared to grill out on his day off.

The train was between Boston and Washington and had stopped for unknown reasons in Delaware. The passengers weren’t sure how long they’d be there. An Amtrak spokeswoman said in an emailed statement that it apologized for the “inconvenience” to passengers and that most people were put on other trains.

Chelsea Kopta, the Amtrak spokeswoman, cautioned about a pizza delivery being made to a train track. She said in the email, “We know train delays can be frustrating, but it is extremely dangerous to approach a train on the tracks. We are glad no one was hurt and hope this is not tried again in the future.”

Leary, 46, said he drove to the address of a nearby house that a passenger on the train had given him and parked on the dead-end street. The site was about a quarter-mile from the pizza shop.

He said he then navigated his way behind a row of houses, past a fence, over a berm and across a small stream — all while balancing two pizzas in a bag.

On Twitter, Mitch Katz posted a video of the pizza delivery, saying he “got hangry and problem solved.”

As he walked along the gully area, Leary said, passengers were waving and cheering.

“It was funny,” he said. As he got close to the train, he said, he called the customer who had placed the order, and the customer guided him to the correct car from a partially opened window.

“The guy was waving and saying ‘I’m down here,’ ” Leary said as he described how the man leaned out of the train. “I told him, ‘I’ll be there in a minute.’ ”

The customer tipped him $12 on a credit card, but when another passenger realized Leary had thoughtfully remembered paper plates, someone handed him a $20 bill.

“It was easy money,” Leary said.

He said it was the first time he has delivered to a train. He can quickly tick off the other odd places he’s delivered pizza, including ballgames, campgrounds, cars stuck in highway traffic, broken-down tractor trailers, boats and carnivals.

“I’ve been robbed and everything else,” said Leary, who says that he has worked as a pizza deliveryman  in 18 states, 28 counties and three parishes. He said he plans to someday write a book about it.

He has worked for Dom’s for two years. He said he has stuck with his pizza delivery career for so long because he likes it.

“I really enjoy it,” he said. “I really like going up to a door and a kid is there yelling, ‘Mommy, mommy the pizza man is here.’

“It’s self-fulfilling,” he said. “Having all the happiness I bring. I like that.”

Of the Amtrak delivery, he said, “I would do anything to help people out and they were starving.”

There was some jockeying on social media Monday over who had ordered the pizzas — one cheese and one pepperoni.

On Twitter, Logan McHugh said his brother, Wade, had placed the order for the pizzas and put up a credit card receipt showing a $23.74 charge.

An earlier version of this story said the train traveling from New York to D.C. It was going from Boston to D.C.