For the choreographer Alexei Ratmansky, the last two years have brought an uncomfortable intermingling of life and art. Known for ballets that combine wit with an almost surrealistic imagination, he has found his thoughts drawn insistently toward the war in Ukraine, the country where he spent his early years and began his dancing career, where he met his wife and where their families still live.

“My parents in Kyiv are awoken at night by explosions,” he said in an interview at Lincoln Center. “It gets harder and harder and heavier because no one sees any light. I can’t stop thinking about it.”

There is one image in particular that he can’t get out of his mind — a photograph of a father kneeling next to his 13-year-old son, killed at a bus stop in Kharkiv during a Russian airstrike. The man stayed there for hours holding the boy’s hand.

Ratmansky, 55, has kept the image filed away, part of a mental gallery of the horrors of war. Now it has found its way into a dance, his first for New York City Ballet in his new role as artist in residence. The piece, “Solitude,” set to music by Gustav Mahler, premieres on Thursday.

“I didn’t plan to do a ballet about this picture, but it haunts me,” said Ratmansky, who has a son in his 20s. “To convey something so dark in pointe shoes, with pirouettes and partnering — it almost feels like I’m entering forbidden territory.”

It seems right that Ratmansky, arguably the most important ballet choreographer working today, is entering that territory at New York City Ballet, where he has made some of his most personal and original work, tapping into the furthest reaches of his imagination. Because of the company’s repertory, built on the ballets of George Balanchine, and because of the dancers’ ethic — “it’s about the choreography and the music, not about them,” he said — Ratmansky feels an open-endedness in the creation process here. “I can say, let’s go in this direction,” he said, “and I know that something will happen.”