Thanks to the tree, I managed not to get wet in the rain.

Literal

Tree [possessive-の] thanks-to, rain [in-に] get-wet-not [and-ずに] finished.

Three useful structures piled together. ~のおかげで ('thanks to') is the positive causal frame; its negative counterpart is ~のせいで ('because of / blaming'). ~ずに is the classical negative conjunctive 'without X-ing' — still very productive in written and semi-formal speech. ~ずに済む ('manage without X-ing / get away without X-ing') is a fixed frame for avoiding an unwanted action.