New Capitals right wing T.J. Oshie helps elevate the Capitals in discussions of Stanley Cup contenders. (Toni L. Sandys/The Washington Post)

As the first night of NHL free agency wound down, the only light and sound on the top floor of the Washington Capitals’ practice facility came from inside the war room. The Capitals had completed several low-profile signings, but General Manager Brian MacLellan’s priority of landing a forward who would fit among the team’s top six remained unfulfilled.

Dinnertime passed without anyone eating. Team officials kept making calls, kept exploring, but worried nothing would get done before it was time to head home.

“The guys we liked were disappearing,” MacLellan later said. “There wasn’t many left. We had holes to fill. If we didn’t find someone, we were in trouble. We were winding it down thinking nothing was going to happen.”

Over the 18 hours that followed, the Capitals made two moves — a signing and a trade — that transformed them from a team that wasted a two-game lead over the New York Rangers in the second round of the playoffs into a trendy Stanley Cup contender pick.

A year earlier, in his first offseason as general manager, MacLellan demonstrated a willingness to take bold action to achieve his goals. Still, few observers, including many of the players who would be involved, anticipated what this July would yield. On the ninth level of Ballston Commons Mall, momentum was building.

Justin Williams, center, struggles for possession during a preseason game. (Gerry Broome/AP)

“There’s adrenaline and it’s intense and it’s fun and it’s frustrating and it’s rewarding and it’s a little bit of everything,” MacLellan said. “There’s pressure on managers and teams. This is a time to improve your roster. It gets harder if you don’t improve your roster after July 1.”

Williams liked Trotz’s pitch

For NHL front offices, the free agency preparation process starts as soon as the last one ends.

“We know who’s unrestricted next year and we’re tracking those guys all year,” MacLellan said, sitting behind his desk at Kettler Capitals Iceplex. “We’ll come in, we’ll have a couple meetings throughout the year, and we’ll rank guys, who we like and who we don’t like, and what our plan is going into the summer. Then as guys sign, or as the situation changes, we adjust our lists.”

So the Capitals knew Justin Williams would hit unrestricted free agency after this past season, but MacLellan assumed the 33-year-old would re-sign with the Los Angeles Kings. When the Kings’ salary cap restraints forced Williams to the open market, the Capitals quickly reached out to his agent, Thane Campbell. Williams boasted postseason success and strong possession-driving metrics, and likely would come at an affordable, short-term price.

Williams, whose NHL career that spanned 16 years, 918 regular-season games and 115 more during eight playoff appearances, was exploring the open market for the first time, and arranged for his two children to spend the first day with their grandmother. But when 10 a.m. rolled around, two hours until players could formally sign with other clubs, Williams and his wife decided to play some tennis.

During a doubles match against another couple, Kelly Williams tossed up the ball served . . . and screamed.

“What happened?” Justin asked.

Neil Greenberg, The Post's stats guru, breaks down the Washington Captials' offseason roster moves and whether the team has enough to seriously contend for the Stanley Cup. (Thomas Johnson/The Washington Post)

“My shoulder popped out,” she replied.

So the Williamses spent the official first hours of free agency at the hospital, arriving at the emergency room around 11 a.m. and later undergoing an MRI exam that would reveal a dislocated shoulder that required surgery.

At the hospital, Justin’s phone kept ringing with updates from Campbell, but the day was moving slowly. By dusk, only a handful of bigger-name players had signed.

Williams and his wife drove home around 5 p.m., when discussions with the Capitals picked up steam. Earlier that day, the Capitals had cast a wider net around right wingers. But with potential targets such as Matt Beleskey (five years, $19 million, Boston Bruins) and Michael Frolik (five years, $21.5 million, Calgary Flames) signing elsewhere, and incumbent forward Joel Ward asking for four-year deal the Capitals weren’t inclined to offer, Williams increasingly looked like the best option.

Campbell and assistant GM Don Fishman had swapped calls throughout the day, and when their salary figures began to align, they agreed that Williams and Coach Barry Trotz should speak. So Trotz called Williams and offered his envisioned role: on one of the Capitals’ top two lines, centered by either Evgeny Kuznetsov or Nicklas Backstrom. Williams listened, told Trotz he appreciated the call and promised he would stay in touch.

“There was a certain comfort in the conversation that this could actually be something that would be good for me,” Williams said.

According to Campbell, Williams rejected more lucrative and longer-termed offers elsewhere to join Washington at $3.25 million in average annual value.

“I had one general manager almost pleading with me to wait, saying, ‘Oh my gosh, that’s an unbelievable deal for Washington,’” Campbell said. “But that team wasn’t the fit Justin wanted.”

The first report landed at 11:25 p.m. The signing was announced shortly thereafter.

“There was some good fortune, I think,” Trotz said. “We were excited as hell. Early in the day we thought there’s no chance we’re getting Williams.”

Said MacLellan: “We just kept talking. I think initially he was looking for more term and more money, and then it got to that point where it made sense for us and we became more assertive. It took all day to get there.

“You’re excited for a while, and then you’re moving on. You’ve got to finish it up.”

It was just before midnight when MacLellan, Trotz and their colleagues walked to their cars. They drove down the block and arrived just as Buffalo Wild Wings was about to close. They had a beer and ate a late dinner. Another busy day awaited.

Oshie trade surprises Brouwer

On July 2, MacLellan continued a conversation he had started with St. Louis Blues GM Doug Armstrong at the NHL draft a week earlier. The subject was the availability of right wing T.J. Oshie, and in exchange the Capitals were offering a right wing of their own: Troy Brouwer. Nothing came to fruition then, but the possibility never went away.

“I think it’s just a matter of the timing of it, when they decided to move him,” McLellan said. “We were involved at that point.”

In addition to Brouwer, St. Louis also wanted a draft pick, which became a third-rounder, and a prospect too, settling on goaltender Pheonix Copley. An undrafted free agent signed out of college, Copley excelled in the minor leagues for the Hershey Bears last season, posting a 2.17 goals against average and three shutouts. One source called him “a deal-breaker” for the Blues. He projects to open this season as their AHL No. 1.

“It gets narrowed down,” MacLellan said. Armstrong was “asking for things and I’m saying I can’t do that, how about this, and he’s saying I can’t do that, what about this?”

Oshie was at a family friend’s house in Minnesota, watching golf and strapped into an electric stimulation machine, one phase of his offseason training. The machine still hummed as Armstrong delivered the news.

That morning, Brouwer had skated at Kettler Capitals Iceplex and afterward chatted with Trotz, both of them playing armchair general manager, speculating about how MacLellan planned to attack free agency. Trotz also arranged for Brouwer to appear at development camp in mid-July, because the seven-season veteran wanted extra work. Thinking nothing was imminent, Trotz soon left the facility to film a television interview. When he returned, the offices had again sprung to life.

“I talked to him that night, and as far as I know, he didn’t even think I was going to be moved,” Brouwer said of Trotz, “and that it all came together really quick and that surprised him.”

In several interviews, Trotz has rationalized the trade like this: The Capitals essentially flipped one season of Brouwer, whose $3.6 million deal expires next summer, for one season of Oshie and then they traded Copley and a mid-level pick for a second season of Oshie, who isn’t an unrestricted free agency until 2017.

“Just their excitement when they were talking to me made me shift from being a little upset that I was leaving my home from the last seven years, that quickly transferred me into getting excited and a little giddy about coming to Washington,” said Oshie, who only advanced past the first round once in five postseasons with the Blues.

“It was a short, fast, roller coaster there from feeling like I’ve let down St. Louis to being exited to start the next chapter here in Washington.”

MacLellan earns positive evaluations

MacLellan tried not to beat around the bush when he called Brouwer, who was at home, doing arts and crafts with his 2-year-old daughter. Contacting Copley, however, proved more difficult; the 23-year-old had ventured upriver with some friends in Alaska and was unreachable for four straight days.

“That’s the hard part,” MacLellan said.

The “fun part” came right before. After ownership promoted him from assistant general manager in May 2014, MacLellan had brokered two deals at his first trade deadline — Curtis Glencross for two picks, Tim Gleason for Jack Hillen and a pick — and spearheaded the lucrative signings of defensemen Matt Niskanen and Brooks Orpik. And with the blue line solidified, Ovechkin pushing 30 years old and an overwhelming sense that the team had come inches away from a Stanley Cup run in 2014-15, the Capitals were squarely in win-now territory.

The outside reviews were overwhelmingly positive. CBSSports graded MacLellan’s offseason an “A.” assembled a panel of 29 hockey analytics experts, who gave the Williams signing 96.4 percent approval. True to MacLellan’s assessment, both will start the season among the top six, and both should help alleviate the departures of Brouwer and Ward on the power play.

MacLellan, on the other hand, was more concerned about reaction from the locker room. The Capitals still had holes in the bottom six, since adding Williams and Oshie’s salaries nudged away forwards Ward and Eric Fehr, the penalty kill needed new forwards, and youngsters such as Andre Burakovsky, Evgeny Kuznetsov and Tom Wilson would be counted upon to make leaps in their production.

But players took notice of MacLellan’s true-to-his-word actions over the past two summers. He wanted defensemen and signed two former Pittsburgh Penguins. He wanted right-wingers, signed one and traded for another. Whatever your assessment of the moves themselves, several players said, MacLellan followed through.

“It’s not easy to go out and do it,” MacLellan said. “You can have the best intentions or plan in the world. It’s hard to execute. I feel fortunate that we did execute. It’s hard to do.

“We were trying to add a right wing through the free agent market and the trade market, and we hit on both. I think it’s unusual, but we executed and I feel good about it.”