San Antonio Spurs’ Rudy Gay (left) shoots against Golden State Warriors’ JaVale McGee (right) during the first quarter in Game 2 of a first-round NBA basketball playoff series April 16 in Oakland, California.

OAKLAND, California — Rudy Gay had amassed just seven career playoff games in 11 NBA seasons. His chances of returning to the postseason were bleak if he remained with the Sacramento Kings. And to make matters more challenging, Gay was recovering from a season-ending Achilles tendon injury.

While watching the opening day of the 2017 NBA playoffs at a sports bar near his offseason home in South Florida, Gay daydreamed about a return to the postseason. Today, he is realizing what he envisioned as a starting forward for the San Antonio Spurs.

“I was in my boot and I was at a local sports bar around my house thinking about what I could be doing, how I could be healthy and how I could be in the playoffs the next year,” the 31-year-old Gay said. “I was down this time of year before because I wanted to play in the playoffs. Yeah, I was pretty down. But I was motivated. It was one of those downs where I was like, ‘I’m not going to let this happen again.’ ”

Frustrated with the losing and rebuilding, Gay opted out of his contract with the Kings that would have paid $14 million during the 2017-18 season. The Kings have not been in the playoffs since 2006. The team also made it less attractive for Gay to return, as they traded All-Star forward DeMarcus Cousins to the New Orleans Pelicans during the night of the 2017 NBA All-Star Game.

Gay helped his free-agent-to-be cause as he averaged 18.7 points and 6.3 rebounds in 30 games with the Kings during the 2016-17 season. He suffered a complete tear of his left Achilles tendon on Jan. 18, 2017, against the Indiana Pacers, ending his season.

Gay had surgery five days later, expecting to be ready for the start of the 2017-18 season. Gay’s agent, Roger Montgomery, recalled a lot of negativity that Gay heard about guys his age who suffer that injury.

“Rudy was motivated to defy the odds and come back strong,” Montgomery said. “So many people said that it was a tough injury that ends careers. Three days after, he said he had this motivation to defy the odds.”

Gay said there was positive pressure that came from opting out of his contract that added to his daily motivation in rehabilitation. The former University of Connecticut star added that he wanted to work as hard as he could for his family, himself and his future team.

“I was down, and I knew I had to do something,” Gay said. “It encouraged me. It was one of those situations that made me get up in the morning. The fact that I wanted to play in the playoffs. The fact that I opted out. I was like, ‘OK, this is your decision, so you have to work your a– off.’ ”

Gay met with the Spurs, Kings, Utah Jazz, Los Angeles Clippers and Oklahoma City Thunder during the first three days of free agency. Montgomery gave each team a medical report detailing everything from surgery to recovery and also made his client’s athletic trainer, Eric Ferguson, available to talk.

The Spurs brought their medical team to meet with Gay and Ferguson. The team was comfortable offering a contract to Gay afterward.

“We needed to add some talent to our team, and he was a gifted player,” Spurs coach Gregg Popovich said. “He can really score, and from all the reports we were getting, his Achilles healed rather quickly. They even thought he would be ready for training camp, which really surprised us. But it made us go ahead and pull the trigger.

“We broke bread together and talked about what would be expected. We talked a little bit about defense, which at the time probably wasn’t his favorite topic. He’s a very intelligent young man, and he knows how we’ve played over the years. I enjoyed my time with him, and it worked out. It’s as simple as that.”

On July 6, 2017, Gay agreed to a guaranteed two-year deal with the Spurs paying $8.4 million this season with a player option for next season paying $8.8 million. The Spurs would be Gay’s fourth team during his NBA career, but also the most accomplished with five championships and 20 straight postseason appearances (now 21 straight).

“I didn’t have to convince them I was healthy,” Gay said. “[The Spurs] said they were confident in their staff. I went from them being confident in me to me being confident in myself and pushing them to let me do more.”

Said Montgomery: “When we looked at what he wanted to accomplish, the Spurs checked just about every box. Their tradition and history is that they win and go deep into the playoffs.”

Gay scored 14 points in his season debut with the Spurs, a 107-99 win over the Minnesota Timberwolves on Oct. 18, 2017. The 6-foot-8, 230-pounder averaged 11.5 points and 5.1 rebounds primarily off the bench in 57 regular-season games. He missed two games with a sore right heel early in the season and also 23 games with right heel bursitis from Dec. 30, 2017, to Feb. 13.

Gay had his best month for the Spurs in April, averaging 15 points, 5 rebounds and 1.3 steals. On April 9, he scored 18 points against the Kings to help the Spurs secure a playoff spot. With Kawhi Leonard likely out for the remainder of the season with a mysterious right quadriceps injury, the addition of Gay has paid off for San Antonio.

“It’s been up and down, but it’s all worth it,” Gay said. “I started the season and then getting hurt and I had to sit out again. At that point [of the heel injury], I was cocky. I felt like if I could come back from my Achilles injury, I could do anything.

“Now looking back, I felt like I was doing too much, and I kind of scaled myself back. Now I feel good. It was all worth it.”

Using a small lineup, the Western Conference’s seventh-seeded Spurs started Kyle Anderson against the reigning NBA champion Golden State Warriors in Game 1 of the first-round series on April 14. After Anderson went scoreless in the first half with the Spurs down 57-41, Popovich started Gay in the second half. Gay finished with 15 points, 6 rebounds and 2 3-pointers in 21 minutes in the Warriors’ 113-92 win.

While Gay wasn’t happy with the loss, Game 1 was meaningful as it was his first playoff game since May 13, 2012, when he and the Memphis Grizzlies lost a deciding Game 7 in the first round to the Clippers 83-72.

“It’s a long haul,” Gay said. “I’ve been on some really good teams. I’ve been on some really bad teams. My whole career kind of led up to [Game 1] and is kind of leading up to where I am going to be in the future. Everybody says a loss is a lesson. I took a lot of losses in my career, and it taught me a lot. I’m not going to let a day pass by.

“I didn’t deal with all the losing [well]. It was tough. All those people you see as your peers out there showing their talents at the highest level, and you’re at home planning your vacation. It’s not something that any competitor wants to do.”

Popovich kept Gay in the starting lineup for Game 2 against the Warriors on Monday. While Gay responded with 12 points on 6-of-12 shooting from the field, 5 rebounds and 3 assists in 31 minutes, the Spurs fell 116-101. Gay and the Leonard-less Spurs return home to San Antonio in a must-win situation in Game 3 on Thursday night if they hope to challenge the Warriors in this series.

“Rudy is always a threat,” Spurs guard Manu Ginobili said. “He’s a guy that can create, and at this point we are struggling offensively too. He’s a player that you can give the ball and he’s going to make something happen. We need players that can score, too, at this point against a team that is tough and athletic.

“We need points. He can provide that for us.”

Montgomery plans to attend Game 3. He feels great about his client’s decision to go to San Antonio.

“To see where he is today starting in the playoffs, with the Spurs excited about the decision after the risk, to see where he is today does it for me,” Montgomery said. “To see him in the lineup [Thursday] is a championship for me.”

Even if the Spurs are eliminated by the Warriors, Gay will have proved that he is not only healthy but also capable of being a regular starter again. The expectation is that he will opt out of his contract to become a free agent this summer. The Spurs are expected to have interest in re-signing him.

What a difference a year has made for Gay. And the 12-year NBA veteran hopes his story of recovering from injury and believing in himself to be able to sign with a winning franchise will motivate others.

“Keep pushing. Nobody can push you like you can push yourself. That is what it is all about,” Gay said.