Connacht's Niva Ta'auso is tackled by Jamie Roberts at the Showgrounds
Cardiff gained significant ground in the Magners League play-off race with this win in Galway.
Ian Keatley kicked four penalties to help Connacht into a 12-10 half-time lead with Casey Laula going over for a Cardiff try.
The Blues improved after the break and Connacht pair Ray Ofisa and Gavin Duffy earned yellow cards.
Dan Parks landed three penalties and Wales lock Davies stormed over for the clinching try six minutes from time.
Keatley's first points came in the third minute, with his kick just nipping inside the left hand post.
Cardiff, who brought Ma'ama Molitika into the back row as a late change, then got their big ball carriers involved.
Ofisa put in a try-saving tackle on Gareth Williams and Connacht stand-in captain Johnny O'Connor was ruled offside at a ruck, before Parks kicked Cardiff level.
The Blues gave away a succession of penalties at the breakdown and after Bradley Davies was penalised, Keatley sent over a fine kick from just inside the visitors' half.
All the early pressure came from Connacht with Sean Cronin, Niva Ta'auso and Fionn Carr probing around the fringes, but David Young's side soaked it up and threatened on the counter.
A penalty was called against hooker Williams for backchat and Keatley duly converted the right-sided kick for a 9-3 lead, with a quarter of an hour remaining in the half.
Cardiff hit back with a well-taken try from Laulala.
The former All Black took a great angle onto a pass in the Connacht 22, glided past Bernie Upton and Mike McCarthy and his clever footwork created enough space for him to stretch over and score by the posts.
Television match official Dermot Moloney confirmed the grounding and Parks added the extras, but some cohesive play from his pack allowed Keatley to restore Connacht's lead late on.
Molitika was held up over the try-line as the Blues made a strong start to the second period, Parks mopping up with a neat penalty from the right.
Ofisa was unfortunate to be sin-binned after he upended Jamie Roberts in a tackle that was not malicious.
Parks did the necessary with the resulting kick and added another to move the Welshmen into a 19-12 lead.
Cardiff upped their physicality, squeezing Connacht in the scrum and there were some huge tackles.
Taufa'ao Filise had a bone-crushing hit on Rodney Ah You and Mike McCarthy left Molitika shuddering.
Parks missed two penalties either side of Duffy's sin-binning for a ruck offence in his 22. And the killer blow came when Davies escaped McCarthy's grasp and handed off Ta'auso on the way to the try-line.
The Blues are now just two points behind the third-placed Ospreys with a game in hand. They welcome Benetton Treviso to Cardiff City Stadium next Thursday.
G Duffy; B Tuohy, N Ta'auso, T Nathan, F Carr; I Keatley, F Murphy; R Loughney, S Cronin, J Hagan; M McCarthy, B Upton; A Browne, J O'Connor (capt), R Ofisa.
A Flavin, B Wilkinson, R Ah You, M McComish, J Muldoon, M Dolan, T O'Halloran, E Griffin.
Chris Czekaj; Leigh Halfpenny, Casey Laulala, Jamie Roberts, Tom James; Dan Parks, Richie Rees; John Yapp, Gareth Williams, Taufa'ao Filise, Bradley Davies, Paul Tito (capt), Andries Pretorius, Martyn Williams, Xavier Rush.
Rhys Williams, Sam Hobbs, Scott Andrews, Michael Paterson, Ma'ama Molitika, Lloyd Williams, Ceri Sweeney, Dafydd Hewitt.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.