The move will see some services moved out of hospitals so people can be treated in the community.
It also aims to boost GP recruitment in north Wales where there has been a shortage.
Health Minister Mark Drakeford said the funding would relieve pressure on GPs.
Most of the money - £23m - will go to health boards and Public Health Wales to improve access to GPs and arrange for services to be moved closer to people's homes.
The remaining funding will be invested in 19 new projects, including:
An extra £34m will be spent on recruiting and training nurses, pharmacists and therapists to work alongside GPs to prevent unnecessary hospital admissions.