We study the production of the exotic charged charmoniumlike state
Z
±
c
(
3900
)
in
p
¯
p
collisions through the sequential process
ψ
(
4260
)
→
Z
±
c
(
3900
)
π
∓
,
Z
±
c
(
3900
)
→
J
/
ψ
π
±
. Using the subsample of candidates originating from semi-inclusive weak decays of
b
-flavored hadrons, we measure the invariant mass and natural width to be
M
=
3902.6
+
5.2
−
5.0
(
stat
)
+
3.3
−
1.4
(
syst
)
MeV
and
Γ
=
3
2
+
28
−
21
(
stat
)
+
26
−
7
(
syst
)
MeV
, respectively. We search for prompt production of the
Z
±
c
(
3900
)
through the same sequential process. No significant signal is observed, and we set an upper limit of 0.70 at the 95% credibility level on the ratio of prompt production to the production via
b
-hadron decays. The study is based on
10.4
f
b
−
1
of
p
¯
p
collision data collected by the D0 experiment at the Fermilab Tevatron collider