The Russo-Japanese war was finally ended when the Treaty of Portsmouth was formally signed, in 1905.
The negotiations of the terms happened in Portsmouth, New Hampshire, hence the name of the treaty, in August.
The final agreement was only signed in September, 1905.
The involvement of the USA occurred because of President Theodore Roosevelt, who brokered in part the negotiations.