T.J. Rivera’s agent initially was hesitant to let the former Met try to resurrect his career with the Long Island Ducks of the lowly independent Atlantic League.

But it took only a month for Rivera’s decision to reject his agent’s advice to start paying off.

The 30-year-old Rivera signed with the Nationals on Saturday night, and was scheduled to report to Double-A Harrisburg on Sunday, Ducks manager Wally Backman confirmed to The Post. Playing at Harrisburg allows the versatile infielder to be called up more quickly to the Nationals than if he were assigned to the Triple-A team in Fresno, Calif.

Rivera was released by the Mets in March without getting a chance to play in spring training and impress new management. A fan favorite when he played in Queens, Rivera missed last season recovering from Tommy John surgery, and had elbow discomfort during spring training.

As an undrafted free agent, Rivera signed with the Amazin’s in 2011, and helped them reach the playoffs as a wild card in 2016. He hit .304/.335/.445 with eight home runs and 43 RBIs in 106 games in parts of two seasons with the Mets.

“I was very surprised [at being released],” Rivera told The Post at the Ducks ballpark in Central Islip two weeks ago.

No teams came calling after he was released, and rather than wait for a workout with an MLB club that may have never come, Rivera in July took Backman’s offer to start from the bottom under his former manager in the Mets farm system.

Rivera finished his stint in the independent league hitting .274/.323/.440 with four home runs and 16 RBIs in 22 games, and joins an organization in the NL playoff race. Entering Sunday, the Nationals (58-52) were tied with the Phillies for the NL’s second wild-card spot.

Rivera, who says he is most comfortable at second base, also played third and first for the Ducks.

“Do I think he can help a championship ballclub? Absolutely,” Backman said last month. “Coming off a bench and being versatile the way he is, he proved that with the Mets. I get it. He’s been out for a year and a half. He could play.”