The former No. 2 government official in Nassau County was indicted Thursday after the FBI caught him giving back a $5,000 payoff from a county contractor, the Brooklyn US Attorney’s Office said.

Ex-Chief Deputy County Executive Richard “Rob” Walker allegedly decided to return the cash after he learned about a grand jury corruption probe — and handed it over to the contractor while the FBI was conducting surveillance.

Walker, 43, was charged with obstruction of justice and making false statements less than a month before the scheduled March 12 corruption trial of his former boss, ex-Nassau County Executive Edward Mangano.