Assign render texture to material

How do I assign a render texture to the material, that is used to show the render texture in runtime?

I have a render texture and a metarial assigned to a gameobject, and the render texture shows up there. But how is it connected to each other?

A RenderTexture is just like any other texture so you can do this:

public Material m;
public RenderTexture r;

m.mainTexture = r;