The charges were filed when he was arrested in February.
Foster was sentenced to two years of probation, 240 hours of community service and $235 in fines after his attorney entered the plea on his behalf.
As part of the sentence, Foster is barred from owning a gun while on probation.
The 24-year-old Foster originally was facing two felony domestic violence charges and a felony weapons charge in the case before his former girlfriend recanted accusations she made against him.
A judge dismissed the felony charges and reduced the weapons charge to a misdemeanor after hearing the ex-girlfriend's testimony during Foster's preliminary hearing last month.
Foster escaped another legal problem when prosecutors in Alabama dropped a misdemeanor marijuana possession charge against him stemming from his arrest in January.
Although Foster's legal troubles are behind him, the former first-round draft selection still faces potential NFL discipline under the league's personal conduct policy.
"We continue to monitor all developments in the matter which remains under review," NFL spokesman Brian McCarthy said in a statement to NFL Network Insider Ian Rapoport.
Foster missed the early portion of the 49ers' offseason program but rejoined the team on May 24 after the felony charges were dismissed.