City Councilman Miguel Martinez resigned yesterday, becoming the first elected official to become a casualty of a sweeping probe into whether government funds given to nonprofit groups were misused.

Martinez — a Manhattan Democrat who took office in 2002 and was in the middle of a re-election campaign for a third term — faces federal charges linked to the alleged misappropriation of funds he steered to a group where his sister served on the board, sources said.

The council recently pulled a new $528,000 grant Martinez tried to give the group, the Upper Manhattan Council Assisting Neighbors, which effectively put the organization out of existence.

Sources said Martinez struck a deal with prosecutors to avoid a grand-jury indictment, and will plead guilty to criminal charges.

He is expected to appear before a judge in Manhattan federal court tomorrow or Friday to approve the deal he struck with prosecutors.

He gave no reason for the move, and many council colleagues were stunned by the news, despite rumors that have been swirling for months that he was in trouble.

Federal authorities, working with the city Department of Investigation, in March, raided UCAN, which was founded in 1998 to assist small businesses in upper Manhattan.

The group received most of its council funding — which totaled more than $1.4 million over the years — after Martinez’s sister, Maria, joined the board as the unpaid secretary.

City and federal authorities have been looking into Martinez as part of a larger investigation into the council’s discretionary spending.

The broader probe, which The Post was the first to disclose in 2008, led to the discovery of a secret slush fund in which council funds were “parked” under the names of fake charities for future allocation to real charities.