I think you played this fine until one mistake. You should have folded this on the river. You made two stabs at the pot that failed. The first smooth call on the turn should have told you to to be wary. In my experience reraises on the river usually have to be respected after a smooth call on the turn. The call here was your bad play. Next time fold this or he might not give you a chance to win it back.