The Nets paid Deron Williams $27.5 million to go away. And on Wednesday night, an injury kept him away.

Williams, who agreed to a buyout with the Nets in July before signing with the Dallas Mavericks, did not play in his Barclays Center homecoming because of a strained hamstring suffered during Tuesday’s game in Toronto.

“It’s very disappointing,” Williams said before the Mavericks’ 119-118 victory over the Nets. “Only come here once. First time back and I get hurt the game before. It’s definitely frustrating missing this game.”

It was somewhat fitting for Williams, who spent four-plus injury-plagued seasons with the Nets. He arrived as one of the best point guards in the league and departed as one of the unhappiest. In a recent interview with Yahoo Sports, Williams called his years with the Nets some of the hardest of his life, saying it “made me question if I even wanted to play basketball when I was done with that contract.”

Asked about his comments Wednesday night, Williams said injuries took the biggest toll.

“I didn’t know if I was ever going to be healthy again,” said Williams, who suffered from ankle issues. “It was hard for me to walk up stairs, hard for me to just have a normal life . . . I’m feeling a lot better now and so that’s not even an option. My mind state is a lot better. I’m happy in Dallas. Happy where I am right now and enjoying playing with this team.”

advertisement | advertise on newsday

Nets coach Lionel Hollins had no comment on Williams, saying, “I have enough worries of my own than to worry about what Deron Williams said and what he thought.”

Williams, 31, has exceeded expectations since signing a two-year, $11-million deal with his hometown Mavericks. Unburdened of the pressures that come with being a highly compensated player in the New York market, Williams has been revitalized, averaging 14.8 points and 5.8 assists per game.

“He’s been playing great basketball for them,” Jarrett Jack said. “One of the reasons they’ve gotten off to such a great start.”

Jack said he keeps in touch with Williams but joked that they talk mostly about Williams’ hair. “Or lack of,” said Williams, who shaved his head before the season.

The Brooklyn crowd was denied the opportunity to see Williams with his new hairstyle and uniform, sparing him from the boos Williams said he expected. Chants of “Where is Deron?” began early in the game.

“I think the way I played was disappointing for fans,” Williams said. “When you are given a max deal and you don’t perform to it, especially in New York, you are going to hear it. So I understand.”

After making the All-Star team during his first full season with the Nets, Williams signed a five-year, $99-million deal to remain in Brooklyn, spurning the Mavericks. The Nets made a series of subsequent moves that mortgaged the future in hopes of becoming contenders. But Williams never resembled the player he once was and the Nets won only one playoff series during his tenure.

Williams, though, has moved on from the unfulfilled expectations, the injuries and the retirement talk.

“It’s behind me now,” he said. “You can’t change anything that happened while I was here. Can’t change being injured. Can’t change how things went. It’s just about moving forward and how I approach the game now.”